285

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.)

9
  • Use 302 or 307 if you want to redirect temporarily... 301 is for permanent redirection...
    – inf3rno
    Dec 7, 2013 at 8: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/) Dec 7, 2013 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 headers 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 7, 2013 at 18:17
  • 1
    FYI - 302 gets cached as well
    – dsmtoday
    Jan 16, 2016 at 1: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 Jan 16, 2016 at 1:42

9 Answers 9

356

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.

16
  • 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. Oct 7, 2014 at 9:22
  • 23
    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 9, 2015 at 21:01
  • 2
    Works in Firefox 50. The end of many hours of frustration.
    – Andy Gee
    Nov 29, 2016 at 7:21
  • 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! Apr 17, 2018 at 14:23
  • 1
    This did not work for me.
    – Flimm
    Aug 16, 2019 at 11:12
36

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"
5
  • This actually works fine, no need to downvote. Jul 19, 2016 at 6:51
  • 6
    This is somehow overkill since it deletes at least the last our of activity, but may be useful. Sep 30, 2016 at 10:24
  • Better to loose the last hour than the whole history, saved passwords etc... Thanks
    – dario
    Dec 13, 2017 at 18:02
  • 1
    Not working in Firefox 66
    – Morteza
    May 23, 2019 at 5:18
  • @dario True, but it may be the case that the redirect was cached a long time ago. As I look now (FF 101.0.1), the options provided are "Last hour", "Last two hours", "Last four hours", "Today" and "Everything", which is very restrictive. So even if it was only yesterday, unless you're still within four hours of the caching event then you're stuck with clearing the entire history.
    – Stewart
    Jun 21 at 19:54
29

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

3
  • 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, 2014 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, 2014 at 15:00
  • When the @RomanSt fails, this helps. +1
    – Olaf
    Nov 2, 2020 at 7: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).

5
  • 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, 2013 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.
    – user194149
    Feb 4, 2015 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, 2017 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.
    – Jahmic
    Apr 25, 2018 at 8:03
  • Thanks, this is the only solution that worked for me. Deleting from history didn't work.
    – hraban
    Apr 15, 2021 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
7
  • Thanks, this is a good scalpel-y way that works for pages that return an error (and thus don't show in history). Apr 8, 2016 at 0: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. Sep 30, 2016 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 bugzilla.mozilla.org/show_bug.cgi?id=1151932 is related, but it discusses similar symptoms.
    – Richlv
    May 2, 2018 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! Aug 3, 2019 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, 2020 at 13:50
7

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.

4
  • 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. Jan 1, 2017 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 1, 2017 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, 2019 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, 2020 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.

2
  • Which is even more of a hassle than just clearing the cache considering your solutions needs a browser restart... Oct 3, 2016 at 7:28
  • 2
    Your question was: "Is it possible to clear only 301-redirects from Firefox's cache?" ...
    – User0
    Oct 3, 2016 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.

1
  • Welcome to Super User! 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, 2018 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!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.