Monday, March 25, 2013

How to Clear Browser Cache Using HTML CODE or PHP CODE

we have  clear the browser cached page or to force the browser to re-download the content of a page, you can use  the following HTML code in the header tags (<head>) of the page. This code will ask the browser to ignore any saved copies of the page, and to re-download page content.



HTML CODE Before used Head Tag 

<!-- no cache headers -->
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache">
<!-- end no cache headers -->

If you doing  work with PHP, you can do the exact same using this PHP code:

PHP Code:

header ("Expires: ".gmdate("D, d M Y H:i:s", time())." GMT");  
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");  
header ("Cache-Control: no-cache, must-revalidate");  
header ("Pragma: no-cache");

3 comments: