简体   繁体   中英

Prevent page caching not working on Android Webkit browser

I'm having troubles with a script which sends HTTP headers to prevent page caching on Android Webkit browsers.Script works fine on popular browser like Chrome, FF and IE but not Android Webkit Browser. I've tested it on 2.1 and 2.2 Androids and page is always cached. When I hit back button page is not reloaded.

Here is my sample script:

<?php

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: no-store, no-cache, must-revalidate");  
header("Cache-Control: post-check=0, pre-check=0", false); 
header("Pragma: no-cache");  

if ($_SESSION['var'] == 1)
$_SESSION['var'] = 0;
else $_SESSION['var'] = 1;

?>
<html>
   <body>
     <a href="http://www.w3schools.com">Go away from current page</a> 
     <p>Value is <?php echo $_SESSION['var']?> .</p>
   </body>
</html>

Webkit浏览器中的此问题的解决方案在“ 为什么Safari不遵守我的缓存控制指令?”一文中提到

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM