【问题标题】:Chrome browser displaying cached content even after fetching fresh content from server即使在从服务器获取新内容后,Chrome 浏览器也会显示缓存内容
【发布时间】:2014-02-04 14:26:21
【问题描述】:

html 页面如下所示:

    Cache-Control:no-store
    Connection:keep-alive
    Content-Encoding:gzip
    Content-Type:text/html
    Date:Tue, 04 Feb 2014 14:51:46 GMT
    Server:nginx/1.4.4
    Transfer-Encoding:chunked


  <html>
    <head>
        <script type=javascript>

    funciton buttonClick(){
        var box = document.getElementById("box");
        box.val = "aaaaaaaaaaaaaaaaaaaa";
    }

    </script>
</head>
<body>

<textarea id="box">bbbbbbbbbbbbbbbbbbbbb</textarea>
<button onclick="buttonClick">button</button>
</body>

</html>

首先我点击按钮...#box.val == "aaaaaaaaa"。然后我访问另一个页面,然后单击返回按钮。 #box.val 应该是“bbbbbbbbbbb”时仍然是“aaaaaaaa”。

我可以看到浏览器已向服务器请求新的 html。但是,浏览器显示“aaaaaaaaaaa”。

当我在浏览器中检查页面源时,它显示“bbbbbbbbbbbbbb”,但显示“aaaaaaaaaaaaaa”。

我的 Chrome 版本是 32.0.1700.102

这不会发生在 FF 或 IE 中。有什么办法可以防止这个问题。

【问题讨论】:

  • 您是否检查过之前的问题,例如 stackoverflow.com/questions/4146813/…stackoverflow.com/questions/16173322/…
  • 我正在使用 Cache-Control: no-store,它仍然会发生。
  • 根据您的评论,您正在使用 Cache-Control: no-store,no-cache,max-age=0;您是否尝试过 Cache-Control: no-store;只有?
  • 是的,我已经尝试了这三者的所有不同组合。在每种情况下,问题仍然存在。
  • 请在代码中包含玩具 HTML 标头

标签: javascript html google-chrome caching cache-control


【解决方案1】:

您的 HTML 标签格式错误(标签名称前有空格)。我确实编辑了您的帖子,但还在下面的代码中发现了其他 javascript 细节问题。

请尝试使用格式良好的 HTML。让我们知道结果。

    <html>
        <head>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-STORE">
            <script type="text/javascript">

        funciton buttonClick(){
            var box = document.getElementById("box");
            box.val = "aaaaaaaaaaaaaaaaaaaa";
        }

        </script>
    </head>
    <body>

    <textarea id="box">bbbbbbbbbbbbbbbbbbbbb</textarea>
    <button onclick="buttonClick();">button</button>
    </body>

    </html>

【讨论】:

  • 好吧,我的代码有点草率,但这只是为了说明问题,它不是 im using. But when you run the code you have posted above, can you recreate the problem Ive 描述的实际代码?
  • 您是否测试了上面的代码,HTML 代码中包含 HTML 标头?
  • 是的,我试过了,但没有解决问题。你能重现这个问题吗?
  • 我认为这个问题是 textareas 特有的。如果您将
猜你喜欢
  • 2016-01-25
  • 2012-08-22
  • 1970-01-01
  • 2016-05-25
  • 2014-06-08
  • 1970-01-01
  • 1970-01-01
  • 2016-09-06
  • 2011-08-12
相关资源
最近更新 更多