Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear browser cache with php?

How to clear browser cache with php?

like image 308
ZA. Avatar asked Jun 24 '09 09:06

ZA.


People also ask

Do PHP files get cached?

I came to the conclusion that, by default, php files are never EVER pulled from cache, even in mobile browsers, even if in the response there is no Cache-Control nor Expires parameter, even if i don't send POST requests and i just follow a link to the page. They are always redownloaded.

How do I clear HTML cache from a website?

The shortcut for clearing the cache on Edge is the same as most of the other browsers: Ctrl+Shift+Del. This will take you to the Clear Browsing Data popup where you check the boxes of everything you want to delete.


2 Answers

header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Type: application/xml; charset=utf-8");
like image 154
ZA. Avatar answered Oct 16 '22 19:10

ZA.


You can delete the browser cache by setting these headers:

<?php
header("Expires: Tue, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
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");
?>
like image 40
user1032289 Avatar answered Oct 16 '22 19:10

user1032289