325

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

Giacomo1968
  • 58,727
ThiefMaster
  • 6,505
  • 9
  • 38
  • 43

10 Answers10

404

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.

Giacomo1968
  • 58,727
RomanSt
  • 9,959
43

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

  • Press Crtl + Shift + Delete.
  • Change the time range, if needed.
  • Click on Details and uncheck everything other than _cache_.
Giacomo1968
  • 58,727
Corneliu
  • 555
34

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,730
27

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,271
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
  • 322
  • 2
  • 5
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,602
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,178
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

Solved!

Tested with Firefox Firefox v103.0,=.

After liking very much the answer from @NoChecksum here. 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

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

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

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

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

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

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

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

Giacomo1968
  • 58,727
0

In my case, somehow maps.google.com got a 301 redirect. Site was not opening because of 301. I checked settings/cache to clear it, but I could only see google.com domain, which would mean un-necessary removing a lot of cache. Finally this worked for me:

  1. Disabling cache completely for firefox. Open "about:config" and disable "browser.cache.disk.enable". Restart firefox (can be done from about:profiles)
  2. Open the site. 301 will not be honoured.
  3. Enable the setting back, and restart firefox again
beria
  • 1