1. Home
  2. General
  3. Disable Cache Using htaccess

Disable Cache Using htaccess

You can disable browser caching using .htaccess file in root folder. You can append rules below on top of your file

<IfModule mod_headers.c>
    Header set Cache-Control "no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires 0

<FilesMatch "\.(css|flv|gif|htm|html|ico|jpe|jpeg|jpg|js|mp3|mp4|png|pdf|swf|txt)$">
    <IfModule mod_expires.c>
        ExpiresActive Off
    <IfModule mod_headers.c>
        FileETag None
        Header unset ETag
        Header unset Pragma
        Header unset Cache-Control
        Header unset Last-Modified
        Header set Pragma "no-cache"
        Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
        Header set Expires "Thu, 1 Jan 1980 00:00:00 GMT"

The only drawbacks from the code above, your site takes slightly longer to load and use more bandwidth.

Updated on August 25, 2023

Was this article helpful?

Related Articles