Reputation: 139
I have tried all the headers i can find in the internet for my webpage not to store the cache, but it doesn't work. I have tried all the php headers, and the HTML meta tags you can ever find.
My webpage only runs smoothly when the " Disable Cache" is ticked under the network tab.
When i look at the cache storage under dev tools there is no data. So i think the headers are actually working, but the data updates when i manually clear the cache in the browser or when disable cache is ticked.
I dont think i have to do anything on the server side as when clear cache is pressed on the browser, everything runs fine.
NOTE: I have tried all solutions from stack overflow.
This is the last one i tried
<?php
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
?>
Upvotes: 1
Views: 3807
Reputation: 177
Cache-Control is an HTTP cache header, Which simply Makes your website Faster, Also it can help your website when using Private Info!!!
Inspect Elements -> Network -> click on the image / file -> Responses Header -> cache-control
For Php
<?php
header('Cache-Control: max-age=86400');
?>
For Apache
<filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=84600, public"
</filesMatch>
For nginx
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires 2d;
add_header Cache-Control "public, no-transform";
}
In that case you need to use :
<?php
header('Cache-Control: no-cache,no-store,must-revalidate');
header('Pragma: no-cache')
?>
If you dont see This taking effect, first try using it on another browser or removing your cache
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
#1 - Is cached #2 - Is not cached
Upvotes: 1