95
votes

Is there any way to disable this 'feature'?

For example, if a request is made to http://localhost/foo.html that I have specified to '301' to the root address, all subsequent requests to foo.html bypass the web server completely and ffox 5 will check it's cache, read that this url was '301'ed previously and redirect without even checking for a change.

If i have stopped foo.html from 301'ing, I have to clear firefox's cache in order to 'fix' this from happening.

Chrome, IE and previous version of Firefox do not do this.

9
Even deleting the cache doesn't resolve this error for me (Firefox 17.0.1, Linux).Konrad Höffner
@kirdie In the "clear recent history" dialog, make sure you set the time range to "everything", and check the "cache" checkbox. If the time range selected is more recent than your visits to the redirected url, the cache entry won't be cleared.Kelvin
@kirdie and everybody with the same problem: Look at the history with Ctrl + H. Then right click the site and choose "delete all history for this site" (or something similar). That did it for me.Lars Nyström
@LarsNyström: Developing a web app and ran into this - your suggestion worked flawlessly for me. It was "Forget about this site" in FF20.0cincodenada
Isn't 301 called "moved permanently" If I have a server serving only https and people go to my domain name using http (bad enough as it is, because they'll reveal the request uri), I would like the browser to remember that permanently and not check http every time.user1115652

9 Answers

125
votes

In Firefox you have the "Web Developer" Tools (Ctrl+Shift+I). You can click "Network" tab and check the checkbox "Disable Cache" to check for new version of page every time. Then load the original URL and it will refresh your cache. Then you can enable the cache again and access that URL also from other tabs. So you don't need to clear your full cache.


From cptstubing06's comment, the following can help clear the cache:

  1. Type Ctrl+l to put the cursor on the location bar.
  2. Type about:config to open the configuration settings.
  3. Confirm any warnings.
  4. Type browser.cache followed by Enter to filter the settings.
  5. Double-click browser.cache.check_doc_frequency.
  6. Change the value from 3 to 1.
  7. Click OK.
  8. Revisit the obsessively cached 301 page.
  9. Reset the frequency back to 3 when finished.

Firefox should now redirect to the new 301 page, no longer fetching the redirected page from cache.

44
votes

301 is just a normal cacheable response code. http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2 says:

This response is cacheable unless indicated otherwise. 

So if you don't want it cached, your server needs to indicate otherwise through the normal headers used to control cache behavior.

You can also clear the cache manually.

25
votes

I just experienced this problem, and for me it was two issues.

This particular domain name is routed through Cloudflare, so I had to set it to development mode. I think Cloudflare was caching the 301 redirect so it didn't have to send the request to the server. This step might not apply to you obviously.

Then, I simply cleared my Firefox cache (version 11) by going to Tools -> Options, clicking the Advanced button at the upper right, selecting the Network tab, and then clicking Clear Now under the section Cached Web Content. Note my cache was already set to 0, but I still needed to click the Clear Now button to get the redirect to stop being cached.

I'd be interested to know if anyone else can verify this.

9
votes

I have found a solution for this that works on Firefox 26, after having an obsolete redirect cached for over a month and a restart.

  1. On the History menu, choose Show All History.
  2. In the search, type in the domain with the cached redirect issue to bring up a list of results.
  3. Right-click on one of them and choose "Forget about this site".

All cached pages, images and redirects for only that site will be removed from the cache. This lets you clear the redirect for your development website without clearing the rest of your cache.

As a side note, I think Firefox should only cache redirects for a few days at most. Caching them for over a month can make a simple mistake a big problem.

5
votes

One quick fix is to use a private browser window.

5
votes

The developer tools built into recent versions of Firefox has a solution for this. First, turn off caching when the dev pane is open:

  • On any page, hit F12 to bring up developer tools
  • At the far right, click the gear icon "Toolbox Options"
  • Under Advanced Settings check the option Disable Cache (when toolbox is open)

Now any time you want to force a refresh of a cached page, load/refresh the page with the F12 dev toolbox open. Firefox will bypass the cache and get fresh data from the server.

I prefer this method because it doesn't change how the browser behaves for "normal" non-debug browsing, and you don't risk forgetting to restore a global setting to its original value.

Verified in Firefox 39

3
votes

A 301 indicates moved permanently. Therefore I see it to be reasonable to cache the response.

Have you tried setting the cache-control and expires headers?

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9

2
votes

In Firefox Version 38.0

Menu -> Edit -> Preferences -> Advanced -> Network -> Clear Now

Worked for me.

1
votes

301 means Moved Permanently and is cachable, so I think that's the "right" behavior for the browser. You should use 303 See Other.