如何阻止缓存中的chrome

时间:2017-08-02 15:16:53

标签: javascript html google-chrome caching refresh

我在这里广泛搜索过这些问题,并且未能找到解决我想要完成的任何解决方案。

简单地说,我有一个html页面,我想每天编辑信息,以便用某人的名字更新办公室周围的仪表板。

该页面在此处,我将其称为子页面

<table border="1" cellpadding="2" cellspacing="0" align="center" style="margin-left: 1.5%; width:98%;">
<tr>
    <td style="background-color:#ff9900;color:#000000;font-family:'Arial Bold', 'Arial';font-weight:700;font-size:24px; text-align:center; color:black" >
    <!-- Support - ext. 8599 - support@sensitive.com <p style="font-size: 16px"id="date"></p> -->
      Sam - x8513 - <p style="font-size: 16px"id="date"></p>   
     <!--  Nick - x8511 - <p style="font-size: 16px"id="date"></p> -->
     <!-- Ian - x8512 - <p style="font-size: 16px"id="date"></p> --> 
    </td>
</tr>
</table>
<script>
    document.getElementById("date").innerHTML = Date();
</script>

这显然是一个不完整的页面,它被引入另一个页面(我将母版页称为iframe,如下所示:

<div style="position: fixed; display:block; top:160px; bottom: 0; Left: 20%; Right: 20%; margin: auto; overflow: auto;">
<iframe src="http://sensitiveinfo.com/Service/ticketstatus/onduty.html" width="98%" height="98%" align="middle" frameborder="0"></iframe>
</div>

困境是,我需要此页面自动刷新。发生的情况是,母版页中包含的所有信息都没有问题,但从子页面中提取的代码不会更新。另一个踢球者 - 这有时只会发生。我每天早上都会更新这个页面,那时我的问题就是刷新了。但是当我强行在机器上进行硬刷新时,它会开始正常运行。令人烦恼的东西。

我在主页顶部存在的刷新/无缓存尝试:

<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta http-equiv="cache-control" content="no-cache" />
<meta name="apple-mobile-web-app-capable" content="yes"/>

<script language="JavaScript">
var sURL = unescape(window.location.pathname);

function doLoad()
{
    // the timeout value should be the same as in the "refresh" meta-tag
    setTimeout( "refresh()", 300000 );
}

function refresh()
{
    window.location.replace( sURL );
}
</script>
</head>
<body onload="doLoad()">

4 个答案:

答案 0 :(得分:2)

您可以使用时间戳让Chrome始终刷新内容

<iframe src="http://sensitiveinfo.com/Service/ticketstatus/onduty.html?<timestamp>" width="98%" height="98%" align="middle" frameborder="0"></iframe>

如果使用查询参数?它会使chrome始终刷新内容,因为它会认为它是一个新页面

答案 1 :(得分:1)

尝试此解决方法:

<iframe src="http://sensitiveinfo.com/Service/ticketstatus/onduty.html?var=xxx" id="theframe"></iframe>

<script>
var _theframe = document.getElementById("theframe");
_theframe.contentWindow.location.href = _theframe.src;
</script>

Source.

答案 2 :(得分:0)

您可以在chrome(F12)和&#34;禁用缓存&#34;中使用开发工具。在&#34;网络&#34;标签。只要dev工具打开,这将禁用缓存。

希望有所帮助

答案 3 :(得分:0)

如果您正在与开发人员进行讨论,那么只需关闭检查员并勾选禁用缓存就会有所帮助。

在您的情况下,我认为这是关于客户的前瞻性如果您从Apache提供该页面,我建议您查看this。这一切都是为了让浏览器知道该文件没有启用缓存,这是HTTP协议头的一部分。

相关问题