How to force a cache MISS

Chris Wright
Published: 3 November 2023Last updated: 3 November 2023
Share:

You can ensure a webpage doesn't cache at the CDN nodes by setting a cache-control header through a .htaccess file. For example, to avoid a webpage caching altogether, you can simply add the following rule into the .htaccess file of the directory of the page being loaded:

# DISABLE CACHING
Header set Cache-Control: no-store

You'll then need to purge the entire cache for the changes to take effect.

To choose specific file types you can add the following to the same .htaccess instead:

<filesMatch ".(jpg|jpeg|png|gif|ico)$">
Header set Cache-Control: no-store
</filesMatch>

To disable cache for a particular file, i.e. login.php, you can add the following instead:

<Files login.php>
Header set Cache-Control: no-store
</Files>

For multiple files, you'd just add two rules.

<Files login.php>
Header set Cache-Control: no-store
</Files>
<Files hello.php>
Header set Cache-Control: no-store
</Files>