Clear a 301 redirect from Google ChromeClear a 301 redirect from Google Chrome

Posted December 27th, 2012 in Applications

Google Chrome caches 301 redirects for a long time. When typing in a URL that you've previously visited that had a 301 redirect on it, it takes you to the redirected location without checking the server again. This could be argued as expected behavior, because it is a permanent redirection after all, but this post shows how you can remove a specific URL from the 301 cache in Chrome.

The reason for doing this

When doing development on a website you can often cock up configuration settings etc (especially with htaccess RewriteRules) which might cause a 301 redirect that you don't really want. This happened to me today and I ended up not being able to get back to the original URL because Chrome kept showing me the redirected location.

I didn't want to clear my entire browsing history, so tried to remove individual URLs from the browser history, and also clearing the browser's history for the last hour, but neither of those worked, and nor did restarting the browser. So I did the following trick instead...

Remove a single 301 redirect in Google Chrome

The redirect cock-up in the configuration was making requests from the homepage at e.g. http://example.com/ go to http://example.com/?q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/&q=/

After fixing your configuration (if you've had a similar issue to mine), view the source of the page you actually want with this url (again using the example.com homepage as the example):

view-source:example.com/

Don't hit enter after typing in the URL. Use Cmd+R on a Mac or Ctrl+F5 on Windows (F5 on its own may also work on Windows, and possibly Ctrl+R - I don't normally use Windows to know).

This will load the source of the page into the browser and clear out that 301, so when you view it normally with the view-source part it should all work OK without the redirect. It might take a couple of goes (it did for me when I tried to replicate the error when writing this post).

Related posts:

Comments

blog comments powered by Disqus