Chrome Caches Redirects
Google Chrome caching redirects, is a known behavior and not one that is planned to change. This is a logical decision, unfortunately the lack of any obvious mechanism to clear these redirects is frustrating at times. There are generally two situations where this occurs.
When the Website Returns a HTTP Status Code Redirect
When a server sends a webpage it includes headers. These headers can include an instruction to redirect the visitor to another page. A common redirect header is the 301 redirect http status code. Once Chrome caches this response, it will automatically redirect to the new location without checking with the server. The problem is that even if the server stops sending the 301 redirect, Chrome will continue redirecting to the new url.
When the Content Contains a Meta Refresh Redirect
In this case, the server responds with a 200 status code indicating that the page loaded just fine. However, in the content of the page is included a redirect meta tag like
<META HTTP-EQUIV="refresh" CONTENT="0;URL=/cgi-sys/defaultwebpage.cgi">
Personally, I’ve found this often arises when creating a new site using cPanel. If you visit the new site before adding an index page, you are redirected to /cgi-sys/defaultwebpage.cgi
. After you add an index page, you’ll find you are still redirected to /cgi-sys/defaultwebpage.cgi
and this redirect is surprisingly difficult to clear.
How to Clear a Redirect from Google Chrome’s Cache
The secret is to use the Chrome Developer Tools, which are built-in to Chrome.
1. Open the Chrome Developer Tools
You can open the Chrome Developer Tools in both Windows and OS X by doing the following:
- Select the Chrome Menu Button
at the top-right of your browser window
- Click More tools in the nav
- Click Developer tools in the sub-nav that opens
2. Open the Chrome Developer Tools Settings
Open the Customize and control DevTools menu by clicking the three vertical dots (in the picture, this icon is highlighted by the red rectangle for emphasis).
Then choose Settings from the nav.
3. Disable cache
Under the Network heading, click the checkbox for Disable cache (while DevTools is open).
Do NOT close the Developer Tools Window.
4. Visit the problem url
In the URL bar, type the url that was being redirected. At this time you should not be redirected.
Fictional Example
Initially, http://example.com/ redirects to http://example.com/cgi-sys/defaultwebpage.cgi
but you then remove the redirect and add content at http://example.com/. Unfortunately, every time you visit http://example.com/ you are still redirected. You can avoid this by using Incognito Mode but that is a short-term fix.
Clear the Redirect
- Open Chrome Developer Tools
- Open the Settings for Chrome Developer Tools
- Check Disable cache (while DevTools is open)
- Visit http://example.com/ and find yourself pleasantly surprised to not be redirected.
How do You Deal with Cached Redirects in Chrome?
I’d love to hear about other ways people are clearing these cached urls.
Thank you!! I was inspecting all my files even going down to WHM config but I knew it couldn’t be an issue with that because my website would work when browsing incognito and in other browsers.
Thanks for the tip
Doesn’t work 🙁
Are you sure the redirect is no longer in place? What is the URL?
It looks like the view-source trick doesn’t work any more – I just get redirected to the redirected URL with view-source prefixed.
Hi Gary,
Based on your comment, I’ve been doing some testing. At this point, it seems there are two different redirect caching problems affecting Chrome.
1. The case where there is a redirect code (e.g. 301) passed back in the header of the response and this gets cached.
2. The case where there is NO redirect code but the actual markup contains a meta tag that redirects.
The view-source trick will correct the second scenario but not the first.
It does appear that using the Chrome developer tools and checking “Disable cache (while DevTools is open)” will correct both cases, so I have updated this post to recommend that technique.
Thanks for your note.
There’s arguably a third method: using cookie data. In this case, the 301 gets passed in the response header but the issue is not that it gets cached, rather the server always responds with a 301 based on the data passed to it in the cookie from the old request.
This just happened to me. I knew something my browser was caching was the problem because the redirect didn’t happen in Incognito mode, but the redirect persisted after disabling cache. Removing the cookies for the domain fixed the problem.
Adding the META tag didn’t work for me because Chrome never read this. Instead, I created a new 301 redirect in my .htaccess with:
Redirect 301 /cgi-sys/defaultwebpage.cgi /index.html
Hi Ben,
To clarify, I’m not advocating adding the META tag. The META tag on the default page is what created the redirect problem. Using “View Source” allowed me to load the page without being redirected so I could refresh the page and clear it from the browser cache.
I like your redirect at the .htaccess level, as well. I’m always glad to have multiple options to solve an issue.
.htaccess does not work for me because the redirect is cached and the .htaccess file is never accessed. NONE of these “tricks” works for me. This is nuts. It seems silly to think a clean install is the only way to access a website.
Hi Hal, I agree cached redirects can be a nightmare though I’ve not yet encountered one that required a clean install of Chrome though that is no guarantee the situation does not exist.
There has been more than one time I’ve banged my head against a cached redirect for way to long only to discover that in fact, I had not removed the redirect. I’ve found curl is a great command line tool to check for this.
curl -I http://example.com/
Will hit the URL and show the HTTP status code returned, anything in the 300s would indicate a redirect.
My next step, would be to use the Chrome developer tools Network panel with the Preserve log option turned on and read the output there.
Good luck.
Thanks! I’ve tried curl. It works fine. FF works fine. wget works fine. w3m works fine. Its only chrome. I’ve tried View Source, Network > disable cache, delete cookies and cache for the last 4 weeks, Incognito mode, manually setting a redirect in .htaccess to over-ride the cached redirect. That doesn’t work because the request never hits the server (verified by checking the server logs). As does the Developer tools logging shows nothing for the same reason. I’ve tried suggestions on other sites, including Google help forums. Its a total time sink.
This is a site under development. I finally just created a different dev domain for it. At some point I have to get some work done :/
I could not view the source because that was redirecting too. Ultimately, I opened the developer console and loaded the page that way, which looks to have cleared the redirect cache.
Good trick, Kevin. The Chrome Developer Console Settings does have a checkbox for “Disable cache (while DevTools is open)”. Info on the topic at https://developer.chrome.com/devtools/docs/settings
This was very simple fix for me.
Just go to clear history and check the clear cache option only. problem solved.
Good point, Eric. Sometimes, clearing your cache via History > Show Full History > Clear Browsing Data can do the trick.
I had the same experience as Eric. It looks like Chrome now does the redirect before loading view-source URLs, but if you open the console, disable caching from there, and then load it, the redirect is cleared even after you close the console.
…why the cached redirect got cleared while caching was disabled Idunno, but hey I’m not going to complain. 😛
Eric’s solution worked for me
I notice that on my Android or iphone browser that on 3g Verizon (non wifi) connections that if I browsed to my website I’d get a /cgi-sys/defaultwebpage.cgi page and if I subsequently went back to wifi I’d get /cgi-sys/defaultwebpage.cgi . I needed to clear the browser cache manually to see my true website homepage. Weeeird. Anyway to stop this happening.
Howie, if I’m hearing you right
When on wifi, your site loads properly
When on 3g, your site redirects to /cgi-sys/defaultwebpage.cgi
If this is correct, my guess is your site is resolving to two different IP addresses depending on whether you’re on Wi-Fi or 3g. Perhaps from a recent DNS change that has not propagated everywhere.
Clearing Browsing History from Chrome worked for me.
That is cool.. nice to know that you can browse source from URL and refresh it. Thanks.
None of the above works for me. Redirect doesn’t happen in incognito or with any othe browser, hence it’s gone. But chrome, not so fast.
That is interesting, AP. I’ve not heard of that happening before. If you want to ping me on Twitter (@salcode), I’d be interested in hearing more about it.
You need to enter you URL in tab where you open dev tools. If you open new tab that trick doesn’t wirk
I also have a 301 that I cannot un-cache. Even with “Disable cache (while DevTools is open)” turned on (and dev tools open), it _still_ caches the 301. The worst part is that the cached 301 had some cookies that were being set, and those are the part that’s really killing me. I’m about ready to just delete anything named *Chrome* in ~/Library to fix it…
Is it possible the redirect is being triggered by the stored cookies? I’ve dealt with code where a value stored in a cookie was triggering the redirect. In that case, I deleted the cookies associated with that site and it resolved my problem.
So, when we’ve got a WP Site, and we put an SSL on the site, I normally force a redirect via .htaccess
That’s basically how I’ve been taught to do it.
However, any site I run through GTMetrix does indeed verify that it’s taking longer to load because of that redirect.
Since you’ve wonderfully made a write up on clearing the redirect in Chrome, any chance you could do a write up on how to solve this redirect problem in a website?
Thanks! -Brad
Hi Brad,
My only thought would be to view source on your page and ensure all your assets (CSS, JavaScript, images, etc.) are being loaded via https. If the assets are trying to load via http and the redirect needs to occur each time, you’re adding an extra round-trip for each asset. I hope this helps. If you’re still stuck, I do offer consultation through my company Iron Code Studio.
People! Clear your browser cache! It solves the problem! However it doesn’t solve it for your visitors. They will get this page forever (unless they clear their cache). Only your new visitors will be able to see your website. If anyone has an idea on how to solve this problem server-side, please let me know.
Hi Dan. I’m unaware of any server side technique to force the client to clear their cached redirect. Since the redirect is cached, the web browser follows the redirect without ever contacting the server. Unfortunately, this makes any change on the server side irrelevant.
There are things you can do ahead of time with Cache-Control and Expires Headers but once the redirects are cached by the browser, it is out of your control on the server side. I find this fact has made me very cautious when setting up redirects.
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).
Here’s what works for me:
Follow the instructions on changing the setting in Chrome Developer Tools.
Open a new Tab.
Hit F12 to refresh the Developer Tools window on this new tab.
Type in the URL and it works!
Hey man, that was awesome! No one on other forums where able to do this. With your permission I’m going to post this link on several forums for people on problems in the future. Thanks!
Thanks for the kind words, Diego. Feel free to share anywhere you like. Cheers.
Sal, thank you so much for this page. I have been banging my head against this problem for two days.
Although I found the new location in the end, would it be possible to revise these instructions in light of how Chrome has rejigged the developer tools menus since you wrote this?
Hi Steve, thanks for pointing out the Chrome UI changes. I’ve updated the instructions and screenshots. Thanks.
Thanks, I spent all day trying to solve it after some changes on my SSL. Sadly I have no idea if my returning visitors will be able to access the site again.
thanks this worked for me. After flushing all DNS and removing all browser cache, history etc. using chrome hidden pages for erasing chrome DNS etc. this was the only working solution.
i have followed the steps u had shown but it still gets redirected to
/cgi-sys/defaultwebpage.cgi
Hi hp,
I would double-check that the redirect is no longer in place on your server.
Personally, I like to do this from the command line of a Mac or Linux machine.
curl -I http://example.com
, where example.com is your site. This should return a200 OK
code if the redirect is gone. If the redirect is still in place, it will be something like301 Moved Permanently
.If you want to post the URL, I’d be happy to check it for you.
I don’t have any idea why this is not appearing on my chrome the first option I have is (Disable JavaScript)
and no option for (Disable Cache) may be because I use a different version of google chrome
I don’t want to remove all my browsers cache as it will not be a good idea, 🙁
thank you anyway and please let me know if there’s any other solution
Thanks for bringing this to my attention. Chrome has moved the Disable cache (while DevTools is open) option under the Network heading. I’ve updated the article to reflect this. Thanks for your help.
thank you!!!!
man, that was frustrating.
THANK YOU! Been driving me crazy trying to get around this cached 302 on a list I’m tweeking cuz a stupid CFO thinks the fonts are too big…then too small… then too big again!!!
I need a new job…
THANK YOU!!! FINALLY!! A real solution that doesn’t need me to clear all cache
I hope someone following this thread can give me advice on a similar issue – I mistakenly set a 301 incorrectly. I corrected the mistake in htaccess. Here is the weirdness:
At my work, where I had never visited the site during this problem, the incorrect redirect is not in effect. Also when I check the redirect it does not appear.
However, at home, where my whole screwup played out, the redirect is still in effect. I”ve tried all of the various cache clearing methods to no avail. Here’s the kicker: This morning I visited the site on one of my kid’s computers, which has not visited the site at all, ever. This computer follows the no-longer-existing incorrect redirect! Even though there is no possible way it is cached in the browser.
This seems to mean that the 301 is cached somewhere out there in the internet. It’s no longer in htaccess, so where could it be? Is it in my router somehow? Is it related to DNS? Anyone have a clue?
Hi William,
I’m hearing you setup a 301 redirect in your .htaccess file, realized it was a mistake, and removed it.
After removing the redirect, you visited the URL from a computer that had never visited the URL previously and you were still redirected. I agree that is odd behavior.
I’d be happy to give it a quick look if you want to:
Great tip, worker like a charam without the need to remove history.
Actually my own testing website had a redirect permanent and I removed but chrome still applying the redirect, only workaround was in incognito windows.
This trick removed the local cached redirect it was bothering me a lot.
Thanks a lot
Since Sal has been of immense help to me, I thought i could add a few cent solutions. If you followed Sal’s solution and all of the other suggestions and you find that your browser/s is still reproducing the page. Clear cookies on other browsers too As some browsers are set to import sessions and cookies from other browsers. You can also try chrome://net-internals. But if all fails and it still persists on your PC esp windows.***** “A simple hard shutdown will do it”.******* Since the session cookies are some how saved in the PC’s RAM. So simply Pressing down your power button and removing the battery will do it. This did it for me after trying every solution out there. I noticed the problem was reproduced in every other browser except Firefox but not on a different device. I even changed server IP to be sure it wasn’t cached somewhere on the web. Sometimes we think the solutions are complex when they are as simple as shutting down your PC; to clear every data cached in RAM.
Thx, bro!
Hi Sal, and all thats been here.
This may- probably is! – be totally off to ask here, but it does include re-directs.
Since this latest round of political madness, ISP’s as we all know now can monitor/track/sell etc. all usage online. That cat’s been out of the bag for a while, silly to think otherwise, however its this next part thats awful. One of the more insidious things is search results redirects – you search using Chrome topbar, then suddenly results are showing in your isp providers search page results, Not from the search engine you picked or use (in my case, Spectrum with Bing search results) that started..wait for it..literally the day that that law got rescinded.
(I reached out to them on Twitter, no reply of course)
Is there a methodology that can be used to circumvent that intrusion, or we all doomed, Doomed! to buying a VPN service to preserve some semblance of privacy?
Best Regards!
Blake
Thankyou! That had been been frustrating me for a day now!
Came to say this worked for me.
Migrating from wordpress to gh-pages
Thank you. This really helped.
Can’t believe I just put up with this issue for so long.
Such a pain in the neck and quite a simple fix.
Thanks
Does anybody know how to clear a redirection that is from HTTP to HTTPS. I have a site (http://yourfamilydata.com) which used to be on a host with HTTPS but the domain has been moved to a different site which now doesn’t have HTTP. Problem is that all Chrome browsers that had loaded the old site are still redirecting to HTTPS, which no longer exists. I cleared the browser cache and even cleared HSTS settings in chrome://net-internals/#hsts but the redirect still happens.
Works fine in incognito mode or other browsers that had never visited the old site.
Same problem here, still no solution..
Hi Alex and Giovanni,
My first choice in this situation would be to add an SSL certificate so the sites run on HTTPS.
Recognizing this isn’t always possible, if I were trying to clear the redirect I would do the following.
Check the HSTS Header is Not Being Sent
If you’re not familiar with how to view your headers, you can check out View HTTP headers in Google Chrome on StackOverflow.
You’re looking for a line that starts with
this is the HSTS header. If you like using the command line (and you have `curl` and `grep` installed), the following command pulls in the headers and looks for the HSTS header. If found it displays the HSTS header, if not it displays a not found message. Replace example.com with your website.
If you are getting an HSTS header, you need to modify your server to stop sending this header.
Clear any stored HSTS header in Chrome
As mentioned in Alex’s post, you can go to
chrome://net-internals/#hsts
to manage stored HSTS values. Using Query HSTS/PKP domain you can check for a stored HSTS value by domain. If you do have an HSTS value stored, you can use Delete domain security policies to remove it.Clear General Redirects
After all of that, I would go through the steps outlined in this blog post to clear any non-HSTS redirects.
Best of luck.
I’ve look into this very extensively recently. This is what I found.
There are two types of redirects “temp” (302) and “permanent” (301). (There are more, but I have not investigated them at this time. Perhaps someone could help here?)
If you use a “permanent” redirect, the browser stores the redirect indefinitely. If you use a “temp” redirect the browser stores the redirect as expired. It will do the redirect, but it marks the redirect as expired immediately after that use.
Thus, if you use a permanent redirect the client’s browser does not contact the server for the initial URL, the client browser only sends what it stored for the redirect to the server. Thus the server has no way to control the client anymore. The only way to correct the problem is to have each and every user clear their cache.
However, if you use a “temp” redirect the browser will ask the server for a new redirect each time it attempts to load the page. This results in slightly greater net traffic, but unless your http://www.amazon.com or something similar, the extra traffic is negotiable. With the client browser asking for the current redirect, the server still has control.
I say “permanent redirects” are considered harmful.
In my experience, I’ve always been told a permanent 301 redirect is preferable for SEO purposes. However, this page from Google https://support.google.com/webmasters/answer/6033049?hl=en includes
Based on this, you may be right that using a 302 redirect is preferable in most cases. However, when I’m working on a project that includes an SEO consultant, I’ll follow their instructions since that is not my area of expertise.
I was having a hard time with a 301 redirect on my website never changing on my browser, even using the network -> Disable cache (while DevTools is open) with dev tools open.
I am not sure if it makes any difference, but initial i had the 301 redirect point to a url on a different domain. I have later changed it to be a url within the domain of redirect. The old domain URL still returns a page. I have never encountered or noticed a redirect be so persistent.
What I did do was use some jquery to perform a get request at the url that was having problems. In DevTools I put in the console: $.get(“https://redirect.url.com/page”) which returned the post response as 200 and I could see the html of the new page I wanted…
Sure enough now my browser redirects to the right place.
Great, I am technical, but now the problem is, how do I get people who visit my site to pick up this change? I can’t explain to everyone to do this.
That is interesting that using the jQuery call worked for you, thanks for sharing.
Unfortunately, I’m not aware of any way to clear redirects on someone else’s machine (all of these tips are about clearing them on your own machine). Best of luck.
This seems to be a very real problem that has been going on for years – a shame it hasn’t been adequately addressed.
Try adding two or three slashes to the end of the domain request, so that http://www.example.com becomes http://www.example.com////
This usually works (although it’s annoying if you then follow a link back to the Home page and there’s your old friend defaultwebpage.cgi again!
There is a simpler solution: https://superuser.com/a/869739
Brilliant! Thanks for this. Very helpful.
Been wondering why force clear cache isn’t working but then I had this hypothesis that redirects cache are more evil.
Thanks a lot.
Incognito mode has its own cache, so caching issues can arise in Incognito mode, Normal mode, or both, depending on which mode was being used when the page was cached.
that worked, many thanks!
Thank you! Worked just like described.
Exactly what I needed. Worked perfectly. Thank you!
Thank you! Works like a charm.
I’ve found this solution before, but had forgotten it. Thanks for giving this knowledge a place on the interwebz!
Thank you ! This bothered me several times. I had to use another browser or an anonymous tab.
OMG thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you thank you
THANK YOU!