Disabling Cache on Linux Server


You can disable caching of files by adding this code to the bottom of .htaccess

<Files index.php>

FileETag None

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"

</Files>


Alternatively to target a specific selection of files, ie. to cache images but nothing else (files that match
html, htm, js, css, php will not be cached):


<filesMatch "\.(html|htm|js|css|php)$">

FileETag None

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"

</filesMatch>

 

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Pages getting 500 error

TVMserver Linux cPanel Hostings uses SuPHP to secure PHP. suPHP is a tool for executing PHP...

Redirect HTTP to HTTPS automatically in Linux / Cpanel

If you have a secure certificate (SSL) on your website, you can automatically redirect visitors...

How to change my document root folder using an .htaccess file?

By default your main website is loaded from the public_html folder of your account. The...

Connection is insecure - SSL certificate issue

First you need to check whether SSL certificate is installed in your hosting account.  You can...