简体   繁体   English

如何停止Chrome的缓存

[英]How to stop chrome from caching

I've searched the questions here pretty extensively, and have not been able to find any solution that solves what I am trying to accomplish. 我已经在这里广泛搜索了问题,却找不到任何解决方案来解决我要解决的问题。

Simply put, I have one html page that I want to edit information on daily to update our dashboards around the office with someone's name. 简而言之,我有一个html页面,我想每天编辑信息以使用某人的名字更新办公室周围的仪表板。

That page is here and I will refer to it as the sub-page : 该页面在这里,我将其称为子页面

<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>

This is obviously an incomplete page, it is being pulled in to another page (I will refer to as the master page as an iframe as follows: 这显然是一个不完整的页面,正在拉入另一个页面(我将其称为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>

The dilemma is, I need this page to auto refresh. 难题是,我需要此页面才能自动刷新。 What happens is, all the information contained in master page refreshes no problem but the code that is pulled from the sub page does not get updated. 发生的情况是,母版页中包含的所有信息都不会刷新,但是从子页提取的代码不会得到更新。 The other kicker--- this only happens sometimes. 另一个踢球者-这只是有时发生。 I update the page every morning and that's when I have problems with it refreshing. 我每天早上都更新页面,那是刷新时遇到的问题。 But when I force a hard refresh on the machine, it starts behaving normally. 但是,当我强制对计算机进行硬刷新时,它会开始正常运行。 Troubling stuff. 令人不安的东西。

My refresh / no cache attempts that exist on the top of the master page: 我的刷新/无高速缓存尝试存在于母版页的顶部:

<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()">

you can use a timestamp to make chrome always refresh the content 您可以使用时间戳使chrome始终刷新内容

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

if you use the query parameter ? 如果使用查询参数? it will make chrome always refresh the content because it will think that it's a new page 它将使chrome始终刷新内容,因为它将认为这是一个新页面

Try this workaround: 尝试以下解决方法:

<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. 资源。

You can use the dev tools in chrome (F12) and "Disable cache" in the "Network" tab. 您可以在Chrome(F12)和“网络”标签中的“禁用缓存”中使用开发工具。 This will disable caching as long as the dev tools are open. 只要打开开发工具,这将禁用缓存。

Hope that helps 希望能有所帮助

If you are talking by the developer's prospective then just pulling off inspector and ticking disable cache will help. 如果您是与开发人员的潜在客户交谈,那么只需拉出检查器并勾选禁用缓存将很有帮助。

In your case I think it's about a client's prospective which If you are serving the page from Apache I would suggest having a look at this . 你的情况,我认为它是关于一个客户的预期,其如果是从Apache的服务页面,我建议在看看这个 It's all about letting the browser know that there is no caching enabled for that file, which is part of the HTTP protocol header. 就是要让浏览器知道该文件没有启用缓存,这是HTTP协议标头的一部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM