: Open a page that redirects without clearing cache I've taken over a website that has an index.html page that redirects. This page gets cached. Obviously clearing the browser's cache entirely would
I've taken over a website that has an index.html page that redirects. This page gets cached. Obviously clearing the browser's cache entirely would solve the problem. Is there any way to go directly to mysite.com and be assured of getting the new page without completely clearing the cache?
I'm looking for something similar to holding shift when reloading a page, only this time for the initial opening of a page.
More posts by @Heady270
3 Comments
Sorted by latest first Latest Oldest Best
Can you rename the existing index.html file to another default directory index filename, like index.htm, default.html, default.htm, or index.php? This won't help when people have index.html cached and go to www.example.com/index.html, but it might help when people go straight to www.example.com/...
When a well behaved web browser encounters cached content, it generally still requests the head portion of the cached document so that it can ensure that the content hasn't changed since it was last cached. Just as long as the last-modified or content-length changes, then you shouldn't have a problem.
Issues arise when your web server has explicitly told web browsers to cache the index page heavilly, or when there's proxy servers inbetween.
I take it you've already changed the index.html page but some users are still redirecting?
Just have that page send out anti-caching headers every time a user loads it. This will force the browser to get a fresh copy of the page every time. You can do this without affecting the caching of the other pages in the site.
You can use meta tags:
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="-1">
In PHP send http headers (You'll have to tell Apache parse the file as PHP)
Header( "Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" );
Header( "Expires: Sat, 26 Jul 1997 05:00:00 GMT" );
Header( "Cache-Control: no-store, no-cache, must-revalidate" );
Header( "Cache-Control: post-check=0, pre-check=0", FALSE );
Header( "Pragma: no-cache" );
In Apache .htaccess
<FilesMatch "index.html$">
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Sat, 26 Jul 1997 05:00:00 GMT"
</IfModule>
</FilesMatch>
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.