Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an application that has the following rewrite rule:

    RewriteCond /tmp/maintenance.html -f
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^(.*)$ /tmp/maintenance.html [L] 

This is our 'maintenance mode'. so I enable maintenance by linking /tmp/maintenance.html with a real file (and keep backdoor access using

Problem is, this page seems to be getting cached by browsers, so when maintenance is turned off, the user has to do a hard refresh in order to get back to the main app.

I'm wondering how I can set the headers for this particular file only in Apache2. I believe there's a no-cache header? I'm assuming I want to set that header for this file, and all should be good.

can someone direct me how to do that, or explain the mechanism by which this static file should never be cached in the user's browser?

share|improve this question
Is it mod_cache or mod_expires that you are using? – Weboide Jul 5 '10 at 14:55
well i'm not using either currently, but there appears to be some default caching going on on the browser end. – brad Jul 5 '10 at 16:23
up vote 3 down vote accepted
<Directory /some/real/path/to/tmp>
  Header Set Pragma "no-cache"
  Header Set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
  Header Set Cache-Control "max-age=0, no-store, no-cache, must-revalidate"
  Header Unset ETag
  FileETag None

That should do it for just about every browser out there.

share|improve this answer
amazing thx.... – brad Jul 6 '10 at 18:42
works in apache 2.2 thanks – danday74 Apr 15 at 10:17

To better control the granularity of the files being excluded from caching, you can use the "FilesMatch" directive.

Also, ensure that mod_headers and mod_rewrite are loaded on the server. If you are not sure, put the header directives in an "ifModule" section:

<FilesMatch "^(excludeme-1|excludeme-2)\.jar$">
    FileEtag None
    <ifModule mod_headers.c>
        Header Unset ETag
        Header Set Cache-Control "max-age=0, no-store, no-cache, must-revalidate"
        Header Set Pragma "no-cache"
        Header Set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
share|improve this answer

Your Answer


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.