I am working on a web application that is using redirects (for pretty URLs).

I am trying to debug logic in the way the redirects are working. However Google Chrome keeps remembering the redirects and even after I change the code, redirecting the same way.

This is making it very hard to troubleshoot.

For example if I redirect /this to /that, then change my code to NOT redirect /this anymore. Google Chrome is still redirecting to /that. Like the redirect is cached or something. Is there a way to turn this off?

  • Does this still happen when you restart? It should stop after you restart with a fresh session – random Jun 30 '11 at 17:12
  • 1
    @random, restarting chrome does seem to fix it. However, I usually have a lot of windows open (ie: docs, db connections, tutorials, the page I am working on, etc.) If I am troubleshooting something it can take several tries before figuring out whats going on. I wouldn't really consider it ideal to have to keep closing all my windows. Thanks. – JD Isaacks Jun 30 '11 at 17:22
  • 2
    Workaround: Use 302 (temporary) redirects while testing, and switch to 301 (permanent) when you're done. (Caveat: Some browsers (Firefox) will cache even 302 redirects when they're going from http to https versions of the same page.) – TRiG Oct 7 '13 at 16:28
  • 1
    Entering a new www.mywebsite/?someparam=somevalue works for me – Mustafa Oct 23 '14 at 17:23
  • 1
    @JDIsaacks you could use a Chrome exclusively to debugging (i.e. Chrome Canary) – athosbr99 Jun 10 '17 at 19:39

17 Answers 17

up vote 311 down vote accepted

Google Chrome will cache your 301 redirects. To get around this, and to keep the tabs open, you'll just need to clear your browser cache.

Chrome Menu Chrome Menu > Settings > Show advanced settings... > Privacy > Click Clear browsing data...

Whatever else you select, make sure "Cached images and files" is a checked option.

Then click Clear browsing data and you should be able to retest again.

If you've just followed the redirect, you only need to delete data from the past hour.

Alternatively, test and develop in incognito mode. There the cache is flushed after the browser is closed.

  • 2
    Latest version of chrome, this option would be "Cached images and files" instead of "Empty the cache" – Dan R Aug 7 '14 at 15:38
  • 22
    I keep getting redirected, even in incognito mode. – Gaia Sep 21 '14 at 16:49
  • 2
    @Gaia yea, that seems to be problem in Chrome incognito. If you are just testing, you might want to use Firefox for this. Firefox private browsing works fine :) – chhantyal Jan 26 '15 at 14:19
  • 8
    Note that HTTP 301 is Moved Permanently so caching the response is perfectly allowed. If you don't want the response to be cached, try 302 or 307. en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection – a CVn Mar 19 '15 at 14:01
  • 6
    The keyboard shortcut for this is Ctrl + Shift + Delete. – 0xcaff Dec 26 '15 at 22:37

This is the sure proof way to clear Chrome's sticky memory for redirects without clearing all your browsing data (method used by the current top answer):

  1. Open the Developer Tools panel (optioncommandi on Mac, or ctrlshifti on Windows)

  2. Click and hold the reload icon enter image description here

  3. A menu will open

    enter image description here

  4. Choose the 3rd option from this menu ("Empty Cache and Hard Reload")

PS: To avoid having to do these steps everytime the redirect is followed by Chrome: check disable cache in DevTools, and while DevTools is open Chrome will bypass the redirect cache (per this answer)

  • 1
    As an aside: this is not available on a Mac. – Arjan Aug 4 '15 at 10:15
  • 3
    this does not always delete cached redirects – Claudiu Creanga Sep 10 '15 at 13:48
  • 7
    It is available on Mac, but the menu is only available if you have the dev tools open. I assume this might be the same on Windows. – Percy Oct 28 '15 at 13:48
  • 1
    @Arjan it is available on a Mac see superuser.com/questions/304589/… – Gaia Oct 28 '15 at 19:24
  • 3
    Mac OS X, Yosemite. Fighting with an http to https permanent redirect, only this option worked. All the others, including the "Disable cache (while DevTools is open)", made no difference. – Carles Sala Feb 11 '17 at 14:29

It's not a perfect solution, but I was able to prevent Chrome from using the cached redirect by passing a bogus query string, or adding a bogus parameter to the existing query string. For example, adding a simple ? to the end of a URL that didn't have q query string worked for me on Chrome 30 on Max OS X.

  • 9
    Yep, this works. example.com becomes example.com?. I'ts the easiest of the bunch – bfred.it Jan 24 '14 at 22:40
  • 2
    This is an awesome trick. I assume you can use this indefinitely ?abc, ?abc2 etc... – brentonstrine May 12 '14 at 20:36
  • 1
    This didn't work for me. Even using a different port (:8080) it changed to https which seems like a Chrome bug. – jwadsack Feb 21 '17 at 19:02
  • I'm already doing the same thing, but it does not work always, sometimes I need to press ctrl+shift+r (ctrl+f5) to get the newer version of the web page, or partial pages included inside the page – M98 Apr 30 '17 at 12:34
  • If there is a wildcard cached 301 this may not work since its "remembering" to forward everything after the TLD. – dhaupin May 22 '17 at 17:16

There's a "wontfix" Chromium bug about this,

That is the expected behavior.

Note that:

  1. You can add cache control headers to a 301 and we'll follow them (expiration etc)
  2. If the resource in question is a subresource, reloading the page will cause the redirect to be re-validated with the server.
  3. You don't have to lose your entire cache. Just follow the redirect and delete the last hour.
  • What does "delete the last hour." means? How to do it? – Mikaël Mayer Jun 10 '15 at 21:03
  • 1
    @MikaëlMayer When you click "History > Clear browsing data", you can select a timeframe to remove data ("the past hour", "past week" etc) – dbr Jun 26 '15 at 13:16
  • No..! Clearing browsing data for a site will not remove the 301 redirect behavior. Not in Chromium 64.0.x anyway – patricktokeeffe Feb 4 at 4:26
  • Clearing "1 hour" makes you logout from all Google products and accounts. What a good advice... – Luciano Fantuzzi Feb 25 at 19:21
  • > You don't have to lose your entire cache. Just follow the redirect and delete the last hour. That's still worse than "delete the last redirect" which is the feature they wontfixed. – rox0r Feb 27 at 17:53

If you have the "Disable cache (while DevTools is open)" option enabled in the DevTools, then simply having the DevTools open is enough to bypass the redirect cache, without constantly throwing away your session.

  • 9
    note: if devTools is open, there is a fast way to delete cache: click on refresh button with right click and choose full reload ;) – user65130 Nov 21 '14 at 17:08
  • 3
    this does not work all the time. I deleted all my cache and still redirecting. Only with incognito mode it works and you get consistent behaviour – Claudiu Creanga Sep 10 '15 at 13:47
  • 2
    Why is this not the top solution? the others are awful by comparison! – Brian Jan 31 '16 at 1:26
  • 3
    Does not work any more... Probably worked in 2014 – Lord Loh. Sep 1 '16 at 17:24
  • @LordLoh. I've just tried this on the latest version of Chrome, and it worked exactly as expected. With the devtools closed, the redirect is cached. Reloading the page with the tools open does not redirect. – Mike Gossmann Sep 1 '16 at 18:58

Chrome caches HTTP redirects and stop checking with the site if the redirect has changed. This can be frustating, since the easiest way to fix (visiting the site and forcing a hard refresh) can't be used because the redirect will happen before you access the link. This is a won't fix issue.

To workaround this, you can clear your browsing data, as explained here or you can follow the steps below and avoid losing your history.

  1. Open the Chrome Developer Tools dev-tools

  2. Click in Settings settings

  3. Check Disable cache (while DevTools is open) disable

  4. Visit the site that you wanted and the cache problem will be solved.

  • 2
    You'll find the option "disable cache" on the network tab too, it is the same option. For debugging redirects I would suggest using the "preserve log", too. – Trendfischer Oct 6 '15 at 12:07

Go to chrome://net-internals and at the far right open the drop-down and choose "Clear Cache". As of version 48, this was the only thing that worked for me to clear a cached 301 (permanent redirect).

  • 1
    Works on Chrome 56 – spencer.sm Feb 9 '17 at 0:13
  • This worked for me thanks – David Van De Meer Jan 18 at 4:09
  • Still works on Chrome 67 – SCO Sep 19 at 8:15

To clear the redirect cache for a single page in Chrome, View Source and do a hard refresh (CTRL + SHIFT + R).

This works as the source browser doesn't automatically follow the 301 redirects.

  • 4
    Didn't work for me in Chrome 25 – swrobel Mar 20 '13 at 23:52
  • 3
    This doesn't work if the redirect is for all pages. I have a www. -> no www. redirect - so the redirect is on the first hit, so I can't refresh anything. Each time I try to go to the page to refresh it follows the 301 - then it's too late! – Ian Grainger Mar 25 '13 at 11:12
  • 1
    @Ian What if you type in the address bar view-source:www.example.com ? Does that let you refresh without it being redirected? – Matthew Blackford Mar 26 '13 at 0:13
  • 1
    @MatthewBlackford AFAICT the same thing, I actually get the source of the redirected page. Not sure my test was that great, though TBH. I've deleted browsing history to 'fix' this problem. – Ian Grainger Mar 26 '13 at 14:07
  • 2
    This only works for javascript and metatag redirects. HTTP redirects are still followed – bfred.it Nov 26 '14 at 15:46

As described here could be caused by HSTS

To get around this, I did the following.

In the Chrome address bar type "chrome://net-internals/#hsts" At the very bottom of a page is QUERY domain textbox - verify that your site (localhost e.g.) is known to the browser If it is, DELETE the localhost domain using the textbox above Your site should now work using plain old HTTP

  • 1
    Hey, thanks. This really helps with sudden https redirects cache. – Ruberoid Jan 3 '16 at 17:46

.dev domains are forced to use HTTPS on Chrome 63+

Since Chrome 63, out December 2017, all domains ending on .dev (and .foo) are forced to use HTTPS via a preloaded HTTP Strict Transport Security (HSTS) header.

More on it here: https://ma.ttias.be/chrome-force-dev-domains-https-via-preloaded-hsts/

  • This was my culprit for sure! I spend HOURS trying to figure out what the hell was going on. Thanks for posting this! – Jabari Dec 16 '17 at 23:25
  • This answer needs more votes. It might not be the problem that the questioner had but it will be for many devs that find this answer in their search results. – bp. Jan 25 at 7:41

If you just want to check the redirects are working as expected it's probably easier to use a command line tool like wget or similar. You can inspect the response headers and redirects are not cached.

In either Chrome or Firefox, you can refresh the redirect by typing "view-source:redirect.yoursite.com" and hitting enter. Then, refresh that page. Now, that should force Chrome or Firefox to refresh the redirect.

  • This is the only answer that worked for me. – JaredThirsk Mar 3 at 21:45

For develop purpose i recommend you in Chrome open DevTools settings and check "Disable cache". Then 30x redirects are not cached and you can debug .htaccess files and so on! enter image description here

  • The strange thing is that this option does not help. I disabled the cache but it still says in the network tab 301 Moved Permanently (from disk cache). – mgutt Oct 25 '17 at 13:34
  • That is same exact thing as clicking 'disable cache' while network tab is open. Nope - does not clear redirects. – bshea Aug 1 at 15:13
  1. Go to chrome://settings/search#clear%20browsing%20data

  2. Click "Clear browsing data"

  3. Check "Cached images and files" (and uncheck the rest if you want)

  4. Click "Clear browsing data"

enter image description here

simplest method, hard refresh. hold Ctrl + R a few seconds. This clears redirects as well as static resources.

  • Why would you hold it instead of simply pressing Ctrl+R? – gronostaj Oct 1 '15 at 18:29
  • @gronostaj Wasn't my answer plain and simple ?? . Without holding, it would be just a normal refresh. Which does not clear cached resources or redirects. – Ryu_hayabusa Oct 7 '15 at 13:02
  • Holding is just like pressing it multiple times. Open Notepad and hold R, multiple Rs will appear. This is exactly the same, but with Ctrl. Holding Ctrl+R is an exact equivalent of pressing it dozen times per second for a few seconds. That's not smart, it's abusing built-in refresh mechanism and relying on undocumented behavior. – gronostaj Oct 7 '15 at 14:06
  • @gronostaj Yes it is an undocumented behavior. The accepted answer does not works for me. That's why i shared it here. I don't see any other way to clear cached redirect . If you know any other methods , feel free to share. – Ryu_hayabusa Oct 10 '15 at 18:44
  • Tried and did not work (301 redirect on whole domain). – mgutt Oct 25 '17 at 13:28

I tried all answers on this page but none worked until I ran flushdns on windows command line window.

C:\Users\DBashyal>ipconfig /flushdns

Windows IP Configuration    
Successfully flushed the DNS Resolver Cache.

FYI, I already had Disable cache checked as mentioned in this answer.

If you don't want to lose your entire cache and your redirect is still stuck in cache, you could try visiting the view-source: version of the url. That refreshed the redirect cache of the same url for me.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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