【问题标题】:Added data is only showed after restarting Internet Explorer添加的数据仅在重新启动 Internet Explorer 后显示
【发布时间】:2013-08-31 09:40:00
【问题描述】:

我用一些简单的 MySQL 数据库活动制作了一个 php 程序。这一切在 Chrome 和 Firefox 中都可以正常工作,但在 Internet Explorer (IE) 中却有些烦人。添加和检索时,我可以在 Chrome 和 Firefox 中看到所有添加的数据,但在 IE 中它不显示。当我再次关闭并重新启动 IE 时,会显示最后添加的数据。它在我看来是一个缓存(刷新?)问题,因此添加了以下 cleach-cache 代码:

<?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");
?>

但这不起作用。我正在使用 Internet Explorer 11,希望有人能帮我解决这个烦人的问题

【问题讨论】:

  • 我自己发现的。事实证明这是一个 AJAX 问题,添加一个随机值可以解决这个问题。好吧,这有点小技巧,但它确实有效。欲了解更多信息:viralpatel.net/blogs/ajax-cache-problem-in-ie

标签: php mysql internet-explorer browser-cache


【解决方案1】:

问题是您的站点未能为缓存资源指定新鲜生命周期,从而迫使 IE 使用启发式算法;见http://msdn.microsoft.com/en-us/library/bb250442(v=vs.85).aspxhttp://blogs.msdn.com/b/ie/archive/2010/07/14/caching-improvements-in-internet-explorer-9.aspx

如果您正确指定它们,您的缓存标头将起作用。您应该发送 Pragmapre-checkpost-check

您的标题应如下所示:

Expires: Tue, 01 Jan 2000 00:00:00 GMT
Cache-Control: no-cache, no-store, max-age=0

这将阻止 IE 在除后退/前进导航(根据设计,忽略服务器的缓存指令)之外的任何其他内容中重用缓存的响应。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-08
    • 1970-01-01
    • 2012-01-11
    • 2022-01-02
    • 2011-09-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多