我有一个使用javascript和许多jax调用的php应用程序。我的应用程序正在使用Firefox。但是当我在Internet Explorer-8或类似版本中运行它时,我的ajax调用会缓存在我的浏览器中,所以我无法用ajax调用输出最新的信息,而是为那些ajax调用的结果提供了旧数据的驻留在浏览器缓存中。如何使用javascript或php禁用Internet Explorer缓存
I have tried lots of possible options as listed below
1.) I added following meta tag in header files
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
2)我加了下面的PHP代码
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
但还是上述2层的方法并没有解决我的问题,即,请任何人可以帮助我来禁用缓存Internet Explorer时,我的应用程序运行,以便它有可能获得最新的信息。
在此先感谢
带HTTP头的第二个解决方案应该可以工作。只要确保头文件真的被发送(使用web-sniffer.net),清除浏览器的缓存(当没有头文件发送时文件可能被缓存)并再次检查。 – duri
*我加了下面的php代码* - 在哪个文件中?响应标题应该放在你的AJAX脚本中。 –
@duri我不相信如果一个项目已经在缓存中,解决方案将工作。我认为你可以使用javascript => http://stackoverflow.com/questions/2099201/javascript-hard-refresh-of-current-page/2099205#2099205来刷新。其余的项目,我认为你应该使用类似filemtime() – Alfred