Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
Does this still happen when you restart? It should stop after you restart with a fresh session –  random Jun 30 '11 at 17:12
    
@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
    
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

7 Answers 7

up vote 45 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.

Wrench > Options > Privacy > Click Clear browsing data...

Whatever else you select, make sure "Empty the cache" 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.

share|improve this answer
3  
Thanks, I think I'll do it incognito. –  JD Isaacks Jun 30 '11 at 17:53
    
If you use incognito mode, it is unnecessary to close the browser. Simply close all incognito tabs. –  MετάEd Feb 3 at 0:21

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.

share|improve this answer

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.
share|improve this answer
4  
+1 for point three. –  Neuralrank Apr 14 '13 at 21:46

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.

share|improve this answer
1  
Didn't work for me in Chrome 25 –  SWrobel Mar 20 '13 at 23:52
    
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
    
@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
    
@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
1  
This worked in Chrome 33. Nice one. –  dav_i Mar 31 at 21:16

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.

share|improve this answer
1  
Yep, this works. example.com becomes example.com?. I'ts the easiest of the bunch –  bfred.it Jan 24 at 22:40
1  
This is an awesome trick. I assume you can use this indefinitely ?abc, ?abc2 etc... –  brentonstrine May 12 at 20:36

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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