刷新iFrame(缓存问题) [英] Refresh iFrame (Cache Issue)

查看:630
本文介绍了刷新iFrame(缓存问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们遇到了一个奇怪的问题,我们不确定究竟是什么原因造成的。让我详细说明这个问题。假设,我们有两个不同的html页面a.html和b.html。和一个用index.html编写的小脚本:

We are getting a weird issue on which we are not sure what exactly cause it. Let me elaborate the issue. Suppose, we have two different html pages a.html and b.html. And a little script written in index.html:

<html>

<head>
    <script>
    function reloadFrame(iframe, src) {
        iframe.src = src;
    }
    </script>
</head>

<body>
    <form>
        <iframe id="myFrame"></iframe>
        <input type="button" value="Load a.html" onclick="reloadFrame(document.getElementById('myFrame'), 'a.html')">
        <input type="button" value="Load b.html" onclick="reloadFrame(document.getElementById('myFrame'), 'b.html')">
    </form>
</body>

</html>

服务器组件不断更新文件a.html和b.html。问题是两个文件的内容都在服务器端成功更新。如果我们打开,我们可以看到更新的更改,但客户端获得的旧内容不显示更新的更改。

A server component is continuously updating both files a.html and b.html. The problem is the content of both files are successfully updating on the server side. If we open we can see the updated changes but client getting the older content which doesn't show the updated changes.

有什么想法?

Any idea?

推荐答案

在a.html和b.html中添加

Add this in a.html and b.html

<head>
    <meta http-Equiv="Cache-Control" Content="no-cache" />
    <meta http-Equiv="Pragma" Content="no-cache" />
    <meta http-Equiv="Expires" Content="0" />
</head>

强制不进行缓存检查

这篇关于刷新iFrame(缓存问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆