Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force browsers to forget cached redirects?

I inherited a domain that previously had a 301 redirect from the root ("/") to "/index.shtml"

I've removed the redirect and a different site on the domain, but people who visited the site in the past will have the redirect behavior cached in their browsers... for a terribly long time, unless they manually clear their caches.

Anyone trying to go to example.com in these browsers will be sent to example.com/index.shtml before they even make any HTTP requests. Right now this is a huge problem because there is no index.shtml, but is there something I can do with headers to tell browsers to "forget about that redirect you just did!"?

like image 837
DMack Avatar asked Apr 30 '14 20:04

DMack


People also ask

How do I remove cached redirects?

Open the Developer Tools Panel by pressing CTRL + Shift + i on Windows or Option + Shift + i on Mac. When you see a developer tools panel open, look the the left of your URL bar to see a refresh icon. Hold the refresh icon for a few seconds until a menu appears. Then click Empty Cache and Hard Reload .

How do I get rid of 301 redirect in Chrome?

Right-click the request that results in the 301 and click "clear browser cache". Try again and then 301 should no-longer be cached. That works well. Alternatively, having the Disable cache checkbox checked in the dev tools while loading the page also does the trick.

Do browsers remember 301?

301 is a cacheable response per HTTP RFC and browsers will cache it depending on the HTTP caching headers you have on the response. Use FireBug or Charles to examine response headers to know the exact duration the response will be cached for.

Can I remove redirects?

You can remove a redirect when you no longer want to redirect a page to another. However, you cannot modify a redirect. If you need to modify an redirect, you will need to delete it and create a new one.


2 Answers

The short answer: There is no way to tell the browsers of the users to "forget" the R 301 redirect. 301 means permanent, it can be only undone on action of the user or when the cache expires.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2

Similar Q and A on Stackoverflow: Apache - how to disable browser caching while debugging htaccess, Cannot remove 301 redirect

Try to avoid 301 redirects and use 302 (temporarily) instead. Here is an article how to set no cache for 301 redirects (didn't try it): https://github.com/markkolich/blog/blob/master/content/entries/set-cache-control-and-expires-headers-on-a-redirect-with-mod-rewrite.md

What you could do in your scenario: You could add a header redirect to the file index.shtml, which sends the user to the original file, where he should usually go.

like image 110
meberhard Avatar answered Oct 23 '22 07:10

meberhard


This can be done by a clear data-only cache. It can remove all,.htaccess redirects changes from the browser.

enter image description here

like image 36
Aayush Rathod Avatar answered Oct 23 '22 08:10

Aayush Rathod