Browser caching issue

I’m running a web site with a LAMP stack, and when I need to perform maintenance on the site, I modify .htaccess to redirect all users to a static “site maintenance” html page.

When I let users back in to the site, a percentage of users still get the site maintenance page.

I know this is a browser caching issue, my question is, is there something I can do (send a php header?) to prevent this from happening? Most of the users are non-technical, so clearing their browser cache would not immediately come to mind for them.

Hmm, I’m using a rewrite rule to do this:

RewriteRule ^/$ error.html

and not a redirect. WOuld that be the problem?

How do you do the redirect?
Perhaps it’s sending a 301 (moved permanently) instead of a 302 (moved temporarily) header.

thanks, will give it a try

Nah, that should be OK.

If instead of using error.html you were to use error.php, you could indeed output some anti-caching headers such as these:


            header("Expires: Mon, 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");

If it helps redirect to the page but tag on something like : ?id=10a9102

Most browsers see variables being passed and think the page is dynamic and dont cache it (unless specifically set to). Same goes for proxies.