9

I was wondering how, if it all, does firefox cache say, google.com to its respective IP?

2 Answers 2

9

It caches it short-term, but I don't know the particulars of the backend. You can see this when DNS doesn't resolve, and you use the refresh button only to find you quickly land on the Server Not Found page again; but, if you click the "Try Again" button on that page, it re-queries the DNS server. Or, if you close and reopen Firefox, the cache will have cleared.

I've found this out through pure experimentation; I've been doing quite a bit of DNS settings changes lately.

This article claims that "In Firefox, by default, the DNS requests are cached for only 1 minute." but it is dated August 2007, so things may have changed by now. (see below)

To control the cache settings, you might try the DNS Cache extension or the Clear Dns Cache extension.

You can also tweak the about:config setting network.dnsCacheExpiration to manually set the cache time; its default is 60 seconds, confirming the above article. Or network.dnsCacheEntries controls the maximum number of cache entries. You will likely need to add these settings to the about:config page yourself (New > Integer), and setting either one (or both) to 0 should disable the cache.

3
  • Values shown in about:networking#dns reveal that Firefox seems to be adding the about:config values network.dnsCacheExpiration (default 60) and network.dnsCacheExpirationGracePeriod (default 60), arriving at a default TTL of 120 seconds (not honouring the TTL returned by the name server, which to my knowledge is against the DNS spec, as caching longer than TTL is forbiddn).
    – nh2
    Apr 5, 2019 at 15:57
  • However, setting these values so that the sum is less than 60 still seems to result in 60 seconds appearing in about:networking#dns. Also, this article and this code suggest that if DNS-over-HTTPS ("TRR") is used, then Firefox will honour the TTL.
    – nh2
    Apr 5, 2019 at 16:15
  • I found the code responsible for setting the sum < 60 not working. valid here is dnsCacheExpiration, grace is dnsCacheExpirationGracePeriod. Indeed it uses valid + grace, and make sure that it's at least 60.
    – nh2
    Apr 5, 2019 at 16:36
6

In the end of 2008 (released in 2009) Mozilla implemented DNS prefetching or pre-resolution in Firefox 3.1 (3.5), the discussion and code changes are available at bugzilla's bug 453403. Since then the defaults are network.dnsCacheExpiration equal to 180 seconds and network.dnsCacheEntries equal to 400 entries. This ensures more cache hits, especially useful when DNS prefetching is enabled. Previous values were 60 and 20, respectively. Check your settings in about:config and if these two have old values update them for better performance.

A look at Firefox's code reveals that network.dnsCacheExpiration is converted to minutes as an integer, so for instance every value in the range 120-179 for this setting equals 2 minutes of TTL. Negative records are cached for exactly 1 minute (not configurable; hardcoded).

If you perform a request for a domain which has been negatively cached Firefox displays the Server not found page with the "Try again" button. At the same time an attempt to resolve the domain again is performed in the background. That's why when there has been just a short problem clicking on the "Try again" button opens the site immediately.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .