How to disable caching 100%

17,887

Solution 1

You can also add Pragma: no-cache. And make sure Last-Modified is far enough in the past: some small clock skews between the client and the server could trick your client into thinking it has a fresh version of the document; use Tue, 15 Nov 1994 12:45:26 GMT for example. And also add an Expires header with date in the past.

Solution 2

I normally add this in my .htaccess

<filesMatch "\.(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, 11 Jan 1984 05:00:00 GMT"
</ifModule>
</filesMatch>

Modify the fileMatch to add other extentions ...

Share:
17,887
user1932232
Author by

user1932232

Updated on June 04, 2022

Comments

  • user1932232
    user1932232 almost 2 years

    Possible Duplicate:
    Cache Control fails

    I am currently using:

    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    

    and

    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="-1">
    <meta http-equiv="pragma" content="no-cache">
    

    Yet it still caches