Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

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?

share|improve this answer
    
I guess there is no way to open a new page the with the same emphasis as CTRL-R will reload a page. Thirty-six hours later everyone is getting the new page, so it may have been a server issue which I'll look into. –  LanceH Sep 20 '10 at 7:51

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>
share|improve this answer
2  
The problem is I already have users stuck with a page that stays cached. Because this page redirects, I can't have them reload that page. I've already replaced index.html with a page which has appropriate headers, I just can't get some users to see it because they can't stay on that page to reload it. Is it possible to load a page, skipping the cache, or will I have to tell my users to clear their cache? –  LanceH Sep 19 '10 at 2:40
    
Good browsers will notice the page has updated by checking the headers each time the user loads the page. But maybe as a temporary solution you can have your home page be named index.htm or index.php (or the extension of your choice) and have the page index.html redirects to redirect to that. Yes, it's a double redirect, but it works around your issue until you can be reasonably sure no users are using the cached page. –  John Conde Sep 19 '10 at 17:05
    
+1 for using eTags. (best-practice) –  Talvi Watia Sep 20 '10 at 3:54

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 http://www.example.com/index.html, but it might help when people go straight to http://www.example.com/...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.