dmck dmck - 1 year ago 82
Apache Configuration Question

How to prevent http file caching in Apache httpd (MAMP)

I am developing a single page Javascript application in MAMP. My JavaScript and HTML template files are getting cached between requests.

Is there a simple way to indicate in MAMP that I want to prevent http file caching? Possibly with a

file? Where do I place the
or modify the virtual host for MAMP on Mac?

Answer Source

Tried this? Should work in both .htaccess, httpd.conf and in a VirtualHost (usually placed in httpd-vhosts.conf if you have included it from your httpd.conf)

<filesMatch "\.(html|htm|js|css)$">
  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 "Wed, 11 Jan 1984 05:00:00 GMT"

100% Prevent Files from being cached

This is similar to how google ads employ the header Cache-Control: private, x-gzip-ok="" > to prevent caching of ads by proxies and clients.


And optionally add the extension for the template files you are retrieving if you are using an extension other than .html for those.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download