How to clear Google Chrome Redirect Cache for a single URL A short tutorial explaining how to clear Chrome's sticky memory for redirects without clearing all your browsing data

How to clear Google Chrome Redirect Cache for a single URL

As you most likely known since you found this post, Google Chrome - just like most other browsers - implements the 301 redirect caching, meaning that it will often locally cache the HTTP 301 redirects for a given amount of time without asking the server another HTTP response for that same URL.

This  is a perfectly fine behaviour, as it's explicitly allowed by the RFC 7231 Section-6.4.2, which says the following:

A 301 response is cacheable by default; i.e., unless otherwise indicated by the method definition or explicit cache controls (see Section 4.2.2 of [RFC7234]).

The only downside of that is that, whenever you're testing or developing a web site (or a web server such as IIS or NGINX) and temporarily configure a HTTP 301 that you want to change later on, you could run into that redirect for a long period of time, thus being unable to access the previously-301 URL, page or resource.

In my specific case it happens all the time, to the point that I always work with my development browsers cache disabled: if I need to test stuff with a non-development browser, I'm often using the Incognito Mode, which flushes its cache everytime the browser is closed. However, such issue can often occur on a non-development browser as well, forcing you to take action in one of the following ways.

#1: Clear All the Browser's Cache Data

You can always fix this issue - together with all caching problems - by clearing all of your browser cache in the following way:

  • Menu > Settings > Show advanced settings > Privacy, then click on Clear browsing data...
  • Ensure that "Cached images and files" is a checked option (the rest is optional, depending on what you want to clear)
  • Click the Clear browsing data button.

This will indeed fix your problem, yet it will also delete your cache data for any other site as well... kinda extreme, isn't it?

Luckily enough, there's a smarter thing you can do, although it requires a bit more work.

#2: Clear Cache Data for a specific URL

This neat method allows you to clear the Google Chrome's Cache Data for a specific URL. It can also be used with other browsers, such as Mozilla Firefox, IE and Edge, as long as they support the same features explained below.

  • Press SHIFT+CTRL+I to open the Google Chrome Developer Tools panel.
  • Go to the Network tab and select the Disable cache checkbox to enable that feature.
  • Type the URL you want to clear from the browser cache in the address bar and press Enter.
  • Click and hold the reload button until a modal window pops up, the select the Empty Cache and Hard Reload hidden option.
  • As soon as the page has been fully reloaded, you can unselect the Disable cache checkbox and disable that feature.

It's worth noting that the Developer Tools panel must remain open for the whole process, otherwise Chrome won't let you to use Empty Cache and Hard Reload feature.

#3: Use the Chrome Incognito Mode

Alternatively, you can always use the Incognito Mode, which flushes its cache everytime the browser is closed. The only downside is that you won't fix your 301 caching issues in the "main" browser: if you want to do that as well, use the above options instead.

#4: Use the Chrome Fetch API

Here's a recent workaround that takes advantage to the Google Chrome fetch() API which has been discovered by one of our readers and definitely seems to work (thanks to Santiago for reporting it!):

  • Go to www.google.com (or any other wesite with a non-restrictive CORS policy - read here if you don't know what we're talking about)
  • Press SHIFT+CTRL+J to open the Google Chrome's console window.
  • Write the following line:

Needless to say, you'll have to replace www.example.com with the actual URL that you want to remove from the cache.

 

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

7 Comments on “How to clear Google Chrome Redirect Cache for a single URL A short tutorial explaining how to clear Chrome's sticky memory for redirects without clearing all your browsing data

  1. Just found out this, seems easy

    Open chrome’s console and:

    fetch(‘https://example.com/path/to/url’, {method: ‘post’}).then(() => {})

    and voilá!

  2. Hmmm, I can no longer find the ‘Disable cache checkbox’ in the Network-Tab of todays Chrome (76.0.3809.132 (Official Build) (64-bit)) and Brave. Nor do I find it somewhere else in the settings. No idea how a developer can remove or hide such an important feature. There should simply be no client-side caching in the browser whenever you open a page in developer mode. Enough trouble to not be fooled by server-side caching…

    I used ‘#3: Use the Chrome Incognito Mode’ for developing and debugging and finally the more clumsy ‘#4: Use the Chrome Fetch API’ to finally refresh the outdated .CSS, That worked well – thank you for this blog post!

    Please note: in Santiago’s post above there ate typographic apostrophes, use simple apostrophes instead (the sample in the blog is correct)!

  3. Pingback: How to Clear Chrome Redirect Cache - @mwender
  4. @TerraD, in Chrome 114 it is working as described here via the checkbox in the network tab.

    @Ryan, thanks for this great article. After having changed a redirect for one of my own domains, it worked in incognito mode but not otherwise, and I absolutely wanted to avoid clearing a 500 MB cache just for that. I prefer a surgically precise intervention, and your article provided me with exactly that.

  5. Pingback: Resolving the “301 Moved Permanently” Error in Nginx – LEMP

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.