<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 ?
Related
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");
?>
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?
<?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' />";
I have a jQuery script in my header that calls a php file.
The php file contains data pulled from a remote xspf file, and the output presented in jQuery for refresh purpose. i have 2 echo rules, one for title and one for listeners. right now jQuery calls the file itself which makes the output appear together on a single line.
how can i make jQuery present these echoes separately so i can control their design (CSS)?
PHP:
<?php
header("Expires: Tue, 03 Jul 2001 06: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");
$xml = simplexml_load_file("http://mysitehere:8000/live.xspf");
foreach ($xml->trackList->track as $data) {
$radio = $data->location;
$song = $data->title;
$info = $data->listeners;
}
echo $song;
echo $info;
?>
jQuery:
<script language="javascript">
jQuery(document).ready(function(){
//Carga al comienzo
jQuery('#salida').load('reader.php');
setInterval(function() {
jQuery('#salida').load('reader.php');
}, 2000);
})
</script>
<div id=salida> </div>
Put the echoed info into separate elements
echo '<div class="Song">'.$song.'</div>';
echo '<div class="Info">'.$info.'</div>';
then setup classes in your css for Song, Info (or whatever names you want to give them)
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.