Home
/
Website Help
/
SuperCacher
/
How to disable the caching on my website

How to disable the caching on my website

Managing the cache on a WordPress website

For WordPress users, we recommend managing the SuperCacher options, including disabling the Dynamic cache through the Speed Optimizer plugin.

Disable the cache on a non-WordPress website

If you are not using WordPress and would like to disable the cache for your website then you can do that by adding the following lines in your website’s .htaccess file:

<IfModule mod_headers.c>
Header set Cache-Control "private"
</IfModule>

This will deactivate all server-side caching for your entire website. To reenable the service delete the lines from the .htaccess file.

Exclude a single page from the cache

You can also exclude only a certain page from the caching with these .htaccess rules:

<If "%{THE_REQUEST} =~ m#/sample-page#">
  <IfModule mod_headers.c>
Header set Cache-Control "private"
</IfModule>
</If>

In the above, replace sample-page with the URI of the desired page.

Exclude all files of the same type from the cache

To disable caching for all files of the same type you can use these .htaccess rules:

<IfModule mod_headers.c>
  <FilesMatch ".(js|css|xml|png|jpg|jpeg|html)$">
    Header set Cache-Control "private"
  </FilesMatch>
</IfModule>

The above will deactivate the caching for all js, css, xml, png, jpg, jpeg and html files. You can replace the list of file extensions to include only the ones you need.

Exclude a specific file from the cache

Alternatively you can disable caching only for a single specific file by adding the following rules in the website’s .htaccess:

<If "%{REQUEST_URI} =~ /filename.php$/">
  <IfModule mod_headers.c>
Header set Cache-Control "private"
</IfModule>
</If>

Replace filename.php with the name of the file you want to exclude from the caching system.

To edit the .htaccess file you can use the File Manager in Site Tools or an FTP client.

Important! Once you save the changes to the .htaccess file you need to purge the Dynamic cache only once from Site Tools -> Speed -> Caching -> Dynamic Cache -> Flush Cache.

Share This Article