I have an application that has the following rewrite rule:
RewriteCond /tmp/maintenance.html -f
RewriteCond %{HTTP_HOST} !^backdoor.myapp.com$
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 backdoor.myapp.com
).
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?
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:
That should do it for just about every browser out there.