Firefox prefetching: what you need to know

Martin Brinkmann
Apr 27, 2013
Firefox
|
20

The basic idea behind prefetching is to speed things up for the user. An algorithm is involved that guesses which resources are likely to be accessed by the user in the recent future.Think of Facebook's login page for instance. The most reasonable assumption is that the user will enter the username and password, and then click on the login link. If you prefetch some of the information you may speed things up for the user in the progress if a prefetched resource is indeed accessed.

While it is in theory an interesting concept to speed things up for the user, critics argue that it is creating unnecessary overhead and that it has privacy implications. Resources that are prefetched but not accessed are wasted for instance as they remain unused. As far as privacy is concerned, the server the information are retrieved from notices the user's connection even if it is caused by the automated process.

Prefetching in Firefox is used in different ways.

Link prefetching based on

The browser supports the prefetch parameter that websites can use to provide browsers with information about resources that they would like it to prefetch. Sites simply need to add the rel="prefetch" parameter to links for that so that Firefox will prefetch the resource when the user connects to the page the link is published on. Prefetching information can also be added as HTML meta tags in the form <meta http-equiv="Link" content="<path/to/resource>; rel=prefetch">

Firefox users can disable this prefetch feature the following way:

  • Type about:config in to the browsers address bar and hit the enter key on the keyboard to load it.
  • Confirm that you will be careful if this is your first time you are opening the page.
  • Search for the preference network.prefetch-next and double-click it to set it to false.
  • Setting it to false disables the feature in the browser.
  • Repeat the process if you want to enable it again at any point in time.

DNS Prefetching

This is another form of prefetching that Firefox supports and makes use of by default. The browser predicts the links that the user is most likely to open to resolve domain names while the user is still on the page. This removes the time it takes to resolve domain names when the user clicks on a link in the browser that was pred icted by Firefox as a priority target. The gain depends a lot on the DNS server and the predictions that Firefox makes.

Two preferences are available in Firefox that determine the browser's DNS prefetching.

  • network.dns.disablePrefetch - if set to true, it will disable DNS prefetching in the browser.
  • network.dns.disablePrefetchFromHTTPS - if set to false, it will enable the DNS prefetching on HTTPS websites. The preference does not exist by default and needs to be created.

Speculative Pre-Connections

The difference between speculative pre-connections and link prefetching is that the former is handled by the browser automatically regardless of directives on the website the user is on, while the latter seems to only be triggered if the prefetch directive is used on the page.

There is another difference: while link prefetching can be disabled in the browser, speculative pre-connections cannot. There is no switch to turn it off and it seems that Mozilla won't implement one. Speculative pre-connections work on network and Internet pages as well as on the new tab page.

So what is the main issue here? Say you are using a laptop at home and work. If you visit NSFW sites regularly at home you may end up with some of them being listed on the new tab page. If you now hover over any link on the new tab page it will get connected to which certainly will make its way in to the logs. You may not only have a hard time explaining to your boss that you did not connect to the site at work, it may also be one of the most embarrassing moments you ever experienced.

There are other situations. You may leak information about a local network when you use the laptop in a public network for example.

Advertisement

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

  1. Nebulus said on April 28, 2013 at 5:17 am
    Reply

    Martin, could you clarify things a bit please? I am running latest ESR (17) from Firefox, so apparently I am not affected by this speculative connections issue. What is or what will be the first Firefox version which will make this kind of (I dare say unwanted) connections?

    1. Martin Brinkmann said on April 28, 2013 at 5:44 am
      Reply

      It is coming in Firefox 22.

      1. Nebulus said on April 28, 2013 at 4:41 pm
        Reply

        Thank you very much, Martin!

  2. EuroScept1C said on April 28, 2013 at 5:03 am
    Reply

    Man… Now I understand why I get those DNS errors in Windows Event Viewer… I was seeing some truly strange sites, somewhat related to my recent searches, saying that failed to connect bla bla!

    Wow!…

    For instance, I just got a new ASUS motherboard, I was searching about, and right now I have in my Event Viewer warnings like: DNS Client Events – Event ID 1014 – Name resolution for the name http://www.asusdesign.com timed out after none of the configured DNS servers responded.

    Meanwhile asusdesign.com is completely unrelated…

    This MUST be turned off…

  3. Andy said on April 28, 2013 at 3:14 am
    Reply

    Yeah, it’s planned for Firefox 22.
    Seems like bad privacy decision.

    I encourage everyone to vote for this bug:

    introduce preference for controlling speculative pre-connections
    https://bugzilla.mozilla.org/show_bug.cgi?id=814169

  4. Andy said on April 28, 2013 at 1:51 am
    Reply

    Just tested Firefox 20 on Linux w/ Wireshark.
    My conclusion: speculative pre-connections only made when you click on search bar / change search provider there.
    Maybe nightly or windows feature?

  5. EuroScept1C said on April 27, 2013 at 4:40 pm
    Reply

    Uhm… wait, what? Are you telling me I can’t disable what I thought I was for so long… Speculative pre-connections my ass -sorry. Damn it!

    1. Martin Brinkmann said on April 27, 2013 at 5:20 pm
      Reply

      Yes as far as speculative pre-connections are concerned. You can’t turn that feature off.

  6. EuroScept1C said on April 27, 2013 at 4:29 pm
    Reply

    I have saved in a .doc many things I change/disable/tweak when I install Firefox after a clean Windows Installation. One of these is to disable this prefetch.

    What my list doesn’t include is, the dns prefetch… I didn’t know about; but it’s been added right now… Thank you!

  7. Compuitguy said on April 27, 2013 at 8:25 am
    Reply

    nice feature

    P.S

    english is not my first language so thought that “pred” “icted” were two separate words

    and thanks to google, got this “Showing results for predicted”

    :D

    1. Swapnil said on April 27, 2013 at 10:52 am
      Reply

      Although English is my second language, yet my knowledge vocabulary is 5 more of that of my first language. Also I like English better than my first language. I know adequate English to read any technology articles (in some rare cases, I need to look for 1 or 2 words) or my school textbooks (yes, I am a school student). Yet, reading the same article or book in my first language is very hard for me and almost impossible without a dictionary.

    2. Martin Brinkmann said on April 27, 2013 at 9:19 am
      Reply

      It can sometimes be an eyeopener (yes, one word).

  8. Transcontinental said on April 27, 2013 at 8:15 am
    Reply

    Concerning speculative pre-connections on a network, by what data are they fed ? There must be a source, which one? History, favorites, cookies, Memory/Disk caches ?
    I know of link and dns prefetching, but nothing of speculative pre-connections which I discover with this article. For the former two I’ve always disabled both and never noticed perceptible differences of page layout, perhaps also because link prefetching is not really widely used and as for dns prefetching, whatever Mozilla may state in dedicated articles, I have never noticed an ounce of a difference but, as Martin writes, also depends on the dns server.

    1. Martin Brinkmann said on April 27, 2013 at 9:23 am
      Reply

      Here is how you test that. Use Wireshark or another traffic analyzer and run it. Open Firefox’s New Tab page and hover over an entry there (do not click). Stop the capture, and you will notice that connections to the site are made and that the DNS is looked-up as well.

      1. Transcontinental said on April 27, 2013 at 10:01 am
        Reply

        OK, Martin, that’s for the ‘new tab’ protocol and I can understand that it is effective indeed. I’m not arguing that speculative pre-connection would be… speculation, but I am trying to understand how, else than within the ‘new tab’, they manage, hence on the network how do speculative pre-connections take their “deploymant” from ?

      2. Martin Brinkmann said on April 27, 2013 at 10:28 am
        Reply

        I do not know, maybe in a similar fashion (on mouse hover?).

  9. Ray said on April 27, 2013 at 7:46 am
    Reply

    Well it will be only a person with poor judgement (aka an idiot) who would look at NSFW sites on a corporate laptop, irrespective of whether you are at home or at the office.

    1. Vegemeister said on April 28, 2013 at 10:20 am
      Reply

      Nowhere does it specify a *corporate* laptop.

    2. Martin Brinkmann said on April 27, 2013 at 8:04 am
      Reply

      This was just an example. Think of other sites, maybe about health related problems, relationships, political or religious views.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.