How to disable cache of Apache?

2020-03-19 14:58发布

问题:

I put only index.html in /var/www/html. The page doesn't update after I changed the contents of index.html and reload.

I already disable cache_module in httpd.conf like this below.

# LoadModule cache_module modules/mod_cache.so
# LoadModule disk_cache_module modules/mod_disk_cache.so

回答1:

if you are using htaccess then you can do like

#Initialize mod_rewrite
RewriteEngine On
<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, 12 Jan 1980 05:00:00 GMT"
  </IfModule>
</FilesMatch>