297

Is it possible to clear only 301-redirects from Firefox's cache? CTRL+F5 doesn't do the job since you just reload the target without caching but do not clear the cached redirect.

An option to disable caching of those redirects completely would be fine, too - but some way (possibly through an extension) to remove those cached redirects would be better.

Note: I'm not looking for answers that disable all caching (including CSS, JS, etc.)

ThiefMaster
  • 6,007
  • 9
  • 36
  • 43
  • Use 302 or 307 if you want to redirect temporarily... 301 is for permanent redirection... – inf3rno Dec 07 '13 at 08:56
  • 4
    I know that. But sometimes you forget to change that or your framework uses one (for example, Flask does so when redirecting from `/foo` to `/foo/`) – ThiefMaster Dec 07 '13 at 12:02
  • 1
    Hmm most of the frameworks turn off cache by debug mode, or you can turn it off manually if you add `no-cache, no-store` headers. That will prevent cache by `301 header`s too, if I am right. If it was cached recently, you can clear the recent cache by `history/clear recent history`. If it was not recent, you can find the site in the history, click on it with the right button and choose `delete this page` or `forget about this site`. Theoretically all of these are working, in practice I never used them to remove a redirection from the cache... – inf3rno Dec 07 '13 at 18:17
  • More answers here: http://stackoverflow.com/q/6980192 – tanius Oct 09 '15 at 21:05
  • 1
    FYI - 302 gets cached as well – dsmtoday Jan 16 '16 at 01:36
  • 1
    "This response is only cacheable if indicated by a Cache-Control or Expires header field." - so unlike 301 it shouldn't be cached all the time – ThiefMaster Jan 16 '16 at 01:42
  • [This](https://superuser.com/questions/173210/how-can-i-clear-a-single-site-from-the-cache-in-firefox#1287318) always works for me, as long as you know the exact URL that you need to drop (read the comment too!) – Janaka Bandara Apr 17 '18 at 14:26
  • @inf3rno How can I do these things if I don't run the website I'm having problems with? – Stewart Dec 19 '21 at 22:47
  • @Stewart You can't. – inf3rno Dec 20 '21 at 09:22

9 Answers9

375

Locate the site you are redirected from in the History sidebar. Right-click it and select "Forget about this site".

No addons required!

P.S. I'm pretty sure this didn't work in the past, but nowadays following the redirect and then clearing the cache for past hour will actually remove the cached redirect.

P.S. The current best solution is to use "Web Developer Tools" (Ctrl+Alt+I), click "Network" and click "Disable cache". Load the original URL. Enable the cache again. The page is refreshed in the cache and the original URL is accessible also from other tabs now.

hynekcer
  • 123
  • 4
RomanSt
  • 9,553
  • 15
  • 56
  • 74
  • Didn't work for me, too. – Frozen Flame May 17 '14 at 04:20
  • 22
    Works for me too. Make sure you delete the history entry of the site you're being redirected *from*, not the site you're redirected *to*. – marcvangend Oct 07 '14 at 09:22
  • Works for Desktop, would like to do the same for Android. – DmitrySandalov Jan 27 '15 at 13:24
  • Worked for me without needing to delete the history of the entire sire being redirected from. – user347375 Mar 28 '15 at 13:58
  • Doesn't work on latest Firefox (version 40) – Breno Leitão Sep 08 '15 at 17:17
  • 24
    Confirmed on Firefox 41. But note: "Forget about this site" will forget the cached pages, URL history (needed for auto-completion) and even saved passwords for the *whole domain*. It says "site", not "page", and this feature seems intended to protect your surf history privacy. It might not be what you want here, so be careful. – tanius Oct 09 '15 at 21:01
  • 2
    Works in Firefox 50. The end of many hours of frustration. – Andy Gee Nov 29 '16 at 07:21
  • I have disabled history in Firefox. So the history list is empty and I can't clear it. :( – checksum Jan 01 '17 at 12:01
  • click on the right side (hamburger ) menu, then `history`, `clear recent history`, select `Today` and check only the `Cache`. Click `Clear now` button. That worked for me. Firefox V - 55.0.3 – mihkov Sep 08 '17 at 08:51
  • 2
    BEWARE! Based on my experience with FF so far (from version 40-something up to the nightly build from Apr. 13), this clears ALL entries (for ALL domains) in the browser *cache* (except for a very few particular websites, whose behaviour I have yet to investigate), not just the site that you are trying to forget! – Janaka Bandara Apr 17 '18 at 14:23
  • Thank you very much! That just worked. (I had accidentally set a 301 redirect for the wildcard subdomain to www.…, which broke all subdomains managed at the secondary DNS … ) – user45469 Jul 22 '18 at 13:06
  • This will also clear cookies, as well as other things. – Flimm Nov 12 '18 at 12:44
  • 1
    This did not work for me. – Flimm Aug 16 '19 at 11:12
  • This doesn't work if the redirect is to another domain. In that case there is no history entry for the domain you were redirected _from_, so there is nothing to click. – Szczepan Hołyszewski Apr 20 '20 at 13:01
  • In Firefox 75, it says "Forget this page", and it seems the cookies are still safe after that. – Jānis Elmeris Apr 22 '20 at 09:37
  • @SzczepanHołyszewski There is if one has browsed the site before it got redirected. In my case, my Internet connection dropped and I was redirected to a diagnostic page, but it would appear that this is wrongly using a 301 code and so I was stuck with this redirect. Still, there is a problem with this 'solution' in that it erases _everything_ about the site, including cookies and saved logins. – Stewart Dec 19 '21 at 23:06
  • This is the right answer, should be accepted. Thanks :) – Levi Jan 09 '23 at 11:05
40

The quickest way to remove the cache in Firefox, which includes 301 redirects, is the following:

  • Press CTRL + SHIFT + Delete
  • Change the time range, if needed
  • Click on Details and uncheck everything other than "cache"
Corneliu
  • 517
  • 4
  • 3
32

Here is the simple solution for this in Firefox:

Hamburger menu -> Preferences -> Privacy & Security -> Clear Data (under Cookies and Site Data)

Make sure "Cached Web Content" is checked. You probably want to uncheck "Cookies and Site Data". And then click "Clear", and it's done.

enter image description here

Flimm
  • 10,206
  • 5
  • 32
  • 40
user1983017
  • 439
  • 4
  • 5
  • 4
    Nice! Unlike my solution, this works even if your only visit to the site is a redirect to an error page, because those don't appear in the history and you have nothing to click "Forget about this site" on. – RomanSt Aug 14 '14 at 16:31
  • 3
    the only problem with this solution is that it doesn't clear **only 301-redirect** as the OP would like. – Loopo Dec 23 '14 at 15:00
  • When the @RomanSt fails, this helps. +1 – Olaf Nov 02 '20 at 07:04
26

The only solution I've found so far - short of clearing the whole cache - is the "Disable entire cache" toggle in Web Developer Toolbar. Once disabled you hard reload the page and you get the new version (remember to uncheck the toggle after you're done).

Matteo Riva
  • 9,031
  • 3
  • 28
  • 33
  • 1
    I see a "Disable DNS cache" option, and that seems to do what I want. Very annoying this caching! Thanks for the tip. – SPRBRN Apr 24 '13 at 13:58
  • Additionally to "Disable entire cache" I had to select "Check For Newer Version Of Page Every Time" for the redirect cache to be forgotten. This is the only solution that worked for me on Firefox 35.0.1. –  Feb 04 '15 at 11:50
  • 1
    this was the only thing that worked for me FF 59.0 - resending the request did not clear it & clearing more caches was not an option – RozzA Mar 12 '17 at 23:57
  • 5
    Somewhat obvious, but this checkbox is in the 'network' tab in the developer toolbar. It's now just called 'disable cache'. I like this because it doesn't wipe all info about the site from the cache. – James John McGuire 'Jahmic' Apr 25 '18 at 08:03
  • Thanks, this is the only solution that worked for me. Deleting from history didn't work. – hraban Apr 15 '21 at 17:40
17

Another solution is;

  • Open the Developer toolbar on the Network tab (Ctrl+Shift+Q or Cmd+Opt+Q)
  • Ensure the "All" or "HTML" filter is enabled on the bottom row
  • Navigate to the URL you're receiving a cached redirect on, as usual
  • Notice the first HTML request will show a 301 in the Network list
  • Right-click that row, choose "Edit and Resend"
  • A pane will display on the right, allowing you to edit the HTTP request. Just click "Send"
  • A new HTML request will show in the Network list, this time (hopefully!) returning a 200
  • Navigate to the URL again, it should work as expected
NoChecksum
  • 312
  • 2
  • 5
  • Thanks, this is a good scalpel-y way that works for pages that return an error (and thus don't show in history). – cincodenada Apr 08 '16 at 00:46
  • 6
    This answer looks complicated, but to me it is the only one that actually answer the OP's question: remove only the 301-redirect cache. – Stéphane Gourichon Sep 30 '16 at 10:28
  • 3
    This does not work with FF 59.0.1, or at least with some requests. Clicking "Send" does nothing. Not sure whether https://bugzilla.mozilla.org/show_bug.cgi?id=1151932 is related, but it discusses similar symptoms. – Richlv May 02 '18 at 19:04
  • 1
    This is actually the only one that worked for me though the second to last option seems to hang on luck. I spent several hours on this annoying issue getting redirect loops in outlook. Thank you! – Ken4scholars Aug 03 '19 at 13:40
  • 1
    Doesn't work in FF 73.0 (Linux). The resent request returns 200, however browsing to the URL still redirects :( – Beli Feb 17 '20 at 13:50
  • This is the best approach among all answers. Nevertheless still like @Beli: I may force the resending, I then get a 200, but when browsing the URL from the nav bar, it uses the cache again giving a 301 instead of having cached that now it is a 200. Upvoted to boost this answer up. But guys, we still need a way to tell FF "and this new request is the valid one, forget about that cache". Isn't there any list of "cached responses" to selectivelly tell "foget about this one"? – Xavi Montero Jul 29 '22 at 08:20
  • After my comment 1 hour ago... Built on top of this answer, I create this other answer https://superuser.com/a/1734256/324451 – Xavi Montero Jul 29 '22 at 09:15
8

Late answer. With Firefox 50.

  1. Open up Web Developer in Firefox (F12)
  2. Open up Toolbox Options (Gear/Cog shape icon on top of Web Developer window)
  3. Under Advanced Settings, check the box Disable HTTP Cache (when toolbox is open).

With Web Developer windows opened, redirect cache will be refreshed.

checksum
  • 2,402
  • 1
  • 19
  • 9
  • 1
    I'm quite sure this disables the whole cache altogether, making reloads of a large application with lots of JS/CSS files - even when running locally - awfully slow. – ThiefMaster Jan 01 '17 at 12:00
  • It's a solution to clear your redirect cache frustration ( almost no way good way to clear it, i disabled history on my browser, other answers above don't solve my problem :( ). Then either close the Web Developer (F12) or uncheck the options then you can continue on development. :) – checksum Jan 01 '17 at 12:06
  • When the checkbox is checked, it doesn't redirect, as expected. However, as soon as I uncheck the checkbox, the redirect returns. It looks like this does not clear the cache. – Flimm Aug 16 '19 at 11:15
  • For Firefox 75, it works best of all the answers. It suffices to hit the url only once, then you re-enable checkbox `Disable HTTP Cache` and the cached redirect is cleared forever. If it doesn't work for you, use the Network tab to look at Response Header named `Location`, maybe the 301 redirect is still served from the site and not from the cache. – kubanczyk Apr 29 '20 at 16:08
2

If you are on windows, and the url is not shown in the browser history

Use a search tool like wingrep or the option "Find in files..." in Notepad++ to search for files under this path:

C:\Users\<user>\AppData\Local\Mozilla\Firefox\...

Search for files that contains both the exact text: Moved Permanently, and the URL that are redirecting.

The search might take a minute, and might return more than one file.

Then simply delete the file(s) found, and restart Firefox.

User0
  • 1,168
  • 1
  • 7
  • 7
  • Which is even more of a hassle than just clearing the cache considering your solutions needs a browser restart... – ThiefMaster Oct 03 '16 at 07:28
  • 2
    Your question was: "_Is it possible to clear **only** 301-redirects from Firefox's cache?_" ... – User0 Oct 03 '16 at 17:42
2

You can clear cached redirects as a part of browsing history, selecting a time range. For the recent Firefox Quantum 57.0.3, here's how to do it:

  1. Click the hamburger menu or the library button next to the search bar.
  2. Click 'History'.
  3. Click 'Clear Recent History...'.
  4. Expand 'Details' clicking a small button next to the label.
  5. Uncheck all but 'Cache'. Optionally: select the preferred 'Time range to clear'.
  6. Click 'Clear Now'.

For earlier versions of Firefox, see @mihkov's comment on the question.

Dmytro
  • 121
  • 2
  • Welcome to [su]! It's good to link to the comment you used for reference, but it's even better to add the context in the answer itself, to make the answer self-contained. That way, someone looking at your answer does not have to read the comment thread first. – jpaugh Jan 11 '18 at 19:53
0

Solved!

Tested with Firefox v103.0

After liking very much the answer from @NoChecksum here https://superuser.com/a/998118/324451 I found that after resending the request it gave a 200 "locally in the inspector" but still did not clear the cached 301. And when loading via URL again, the cache was used again.

Clue = TL;DR

In Inspector | Network there's the option Disable cache.

  1. Check.
  2. Load.
  3. Uncheck.
  4. Load again.

Voilà the 301 has gone.

How to reproduce

I'm sharing here the full process to reproduce "force FF to cache the 301" and then "force FF to forget the 301". Here's how I did it in 8 steps:

  1. I installed a docker with a wordpress in port 80 in localhost. There are a myriad ways to enable/disable 301 and 200 back and forth, but running a predefined docker image is a split-second. Any other way would work too. After lanching the docker I just set the data for my DB connection and continued until I had something running. I randomly called the site Tiendas during the installation process.

Running a wordpress

  1. I then entered the database and told the wordpress it was installed in a random port 7901 (where there's nobody listening). This was to "force" the 301 Redirect and force Firefox to cache it. going to nowhere.

In HeidiSql I tuned the fort to force a 301 redirect

  1. I went to my firefox and loaded 127.0.0.1 and the apache responded 301 Redirect by transferring 303 bytes. This redirection told Firefox to go to 127.0.0.1:7901, which yielded in a second request and finally rendering Unable to connect.

I forced Firefox to cache the 301 redirect

  1. I tested Firefox was using the cache. Loaded 127.0.0.1 in the URL but as we can see in the inspector, it did not send a request. It was using the cache so the URL ends up being 127.0.0.1:7901 giving Unable to connect. So we checked the cache "is in place".

Testing the 301 was cached

  1. Now I set back the apache to answer a 200 via telling the wordpress it's no longer in 127.0.0.1:7901 but in 127.0.0.1, so a request to 127.0.0.1 should answer the contet of the home page with a 200 ok. I set it touching the database directly:

Resetting the wordpress to the proper place

  1. Now it comes the fancy part. I set again 127.0.0.1 in the URL. But (and this is the original problem in this question) Firefox kept insisting in using the cache. Of curse Firefox did not know that things in the backend changed. So we ended up again (incorrectly this time) into 127.0.0.1:7901 with a Unable to connect while there's a server behind willing to serve us.

Firefox still used the cache even if in the server there's somebody desiring to give us a 200 okey

  1. Now it comes the magic: In the Inspector | Network enable the Disable Cache option and load 127.0.0.1. We can see it loads the page again (this time 10.34 KB transferred and also it loads all the contents (css, js, etc.). Voilà! We now have in the URL the desired 127.0.0.1. No redirects, no caches, nothing. All forced to be loaded. We can see the Tiendas site.

The cache is forced to be ignored

  1. The time to see the truth... will it work? I unchecked the Disable Cache option to enable caching. Then loaded 127.0.0.1 again. I can see that now FireFox is loading cached what it can (for example the js, ico, etc.) and it is not using the old cached 301. Just this 301 has been completely forgotten and not redirected to 127.0.0.1:7901 anymore.

It works

Hope it helps!

Xavi Montero
  • 523
  • 6
  • 19