trying to Clear browser site cache in php,
for firefox browser is working fine, as we want but when i run in chrome it didnt work.
see code,
header('Clear-Site-Data: "cache", "cookies", "storage", "executionContexts"'); //Firefox
// Crome
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
header('Clear-Site-Data: "cookies"');
return $this->getSuccessResponse("Token Valid");
I think you can't clear cache from browser perfectly, one only option is you can do manually. There is some code. I hope it will work.
<?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");
?>
Related
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
<?php
function clearBrowserCache() {
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate");
header ("Pragma: no-cache");
}
clearBrowserCache();
$_SESSION['test']="demo";
//echo $_SESSION['test'];
clearstatcache() ;
?>
this code is only allowing browser to not to catch cache .but i want to delete all cache using simple code is there any way to do it ? simply i when i run this code my browser's cache should get deleted. how to do it ?
i tired doing an csv export. I needed two languages (tamil and english) in the sheet using normal headers
$now = gmdate("D, d M Y H:i:s");
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
header("Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate");
header("Last-Modified: {$now} GMT");
header ( 'Content-Type: application/vnd.ms-excel') ;
header("Content-Disposition: attachment;filename={$filename}");
header("Content-Transfer-Encoding: binary");
echo $content;
This was causing problems in the tamil characters being displayed. But the format of the excel was fine. So i used a UTF8 encoding to display the tamil characters as shown below.
$now = gmdate("D, d M Y H:i:s");
header('Pragma: public');
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Last-Modified: {$now} GMT");
header('Content-Type: text/csv');
header("Content-Disposition: attachment;filename={$filename}");
header("Content-Transfer-Encoding: binary");
echo chr(255) . chr(254) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8');
This helped with the characters and both languages are being displayed fine now but the format of the csv being generated is disrupted. Everything is being displayed in a single column. Is there anyway to solve this?
So I have this at the very top of my PHP file:
<?php
// Set headers
header('Content-Type: text/html; charset=UTF-8');
header('Content-Style-Type: text/css');
header('Content-Script-Type: application/javascript');
header('HTTP/1.1 200 OK');
header('Content-language: en-US');
header('X-Powered-By: ');
header_remove('X-Powered-By');
header('Last-Modified: Tue, 01 Jan 2013 00:00:00 GMT');
header('Cache-Control: no-store, no-cache, max-age=0, must-revalidate');
header('Pragma: no-store, no-cache, max-age=0, must-revalidate');
header('Expires: Tue, 01 Jan 2013 00:00:00 GMT');
?>
So when I check the Firefox console's NET tab on my site's URL I don't see the Last-Modified header. Any suggestions?
You're telling the browser to cache nothing and he MUST revalidate everything. So the last-modified header doesn't matter.
<?php
$docName = "testdoc";
header("Expires: Mon, 26 Jul 2020 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Type: application/msword; charset=ISO-8859-1");
header("Content-Disposition: attachment; filename=\"".$docName.".doc");
#/ Create and format your text using HTML, its simple stuff ... trial and error ;)
echo '<img src="logo.gif" />';
?>
Soumya Sarkar
Hi I got this following code from google to generate a Doc file by php. But I am unable to put any image there. Can anybody help me with it?
It requires the link, you will need to host the images online in order for the image to be shown on the doc.
Try this and it is working:-
echo "<img src='http://i.imgur.com/MJ5Sa.jpg' />";
Guys please tell me how to prevent from session restore on back button in ubuntu ?
session_cache_limiter( FALSE );
session_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: max-age=0, no-cache, no-store, must-revalidate, post-check=0, pre-check=0'");
header("Pragma: no-cache");
header("Cache-Control: post-check=0, pre-check=0", FALSE);
this works in xp but not in ubuntu.