Reputation: 605
It's not the fist time that i stuck to this problem. Everytime when i use an 301 redirect, the browser caches it. When i change the redirect in my app, i manualy have to clear my browsers cache.
This is not very welcome for an website as you will understand. Is there an solution to avoid this caching?
Currently i got an list of new redirects from my customer. In my .htaccess, i replaced the old ones for the new ones, but it doesn't toke effect.
When i cleared my browser cache, it seems to work propper.
Any solutions? Thanks a lot!
Upvotes: 4
Views: 12293
Reputation: 258
Here's one more relevant quote from HTTP/1.1 spec (in addition to @Bruno 's answer):
13.4 Response Cacheability
...
A response received with a status code of 200, 203, 206, 300, 301 or 410 MAY be stored by a cache and used in reply to a subsequent request, subject to the expiration mechanism, unless a cache-control directive prohibits caching.
https://www.rfc-editor.org/rfc/rfc2616#section-13.4
Upvotes: 1
Reputation: 122649
To quote the HTTP specification on the 301 status code:
301 Moved Permanently
The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.
Hence, the fact that browsers cache the redirected URI shouldn't be a surprise, since it's done as specified.
To get around this problem, most sites use 302 (307 could also be used).
Upvotes: 17