Chrome 的应用程序缓存不更新文件,即使它说:应用程序缓存下载事件

Chrome's App Cache don't update files even it says: Application Cache Downloading event

我在我的网络应用程序中配置了应用程序缓存清单,chrome 检测到它的内容何时更改,触发 "Application Cache Downloading event" 但内容未更新。

它可以是什么?

据我所知here :

THE APPLICATIONCACHE IS AN ADDITIONAL CACHE, NOT AT ALTERNATIVE ONE When the browser updates the ApplicationCache, it requests urls as it usually would. It obeys regular caching instructions: If an item’s header says “assume I’m good until 1st April 2022” the browser will assume that resource is indeed good until 1st April 2022, and won’t trouble the server for an update. This is a good thing, because you can use it to cut down the number of requests the browser needs to make when the manifest changes. This can catch people out while they’re experimenting if their servers don’t serve cache headers. Without specifics, the browser will take a guess at the caching. You could update whatever.html and the manifest, but the browser won’t update the file because it’ll “guess” that it doesn’t need updating. All files you serve should have cache headers and this is especially important for everything in your manifest and the manifest itself. If a file is very likely to update, it should be served with no-cache. If the file changes infrequently must-revalidate is a better bet. For example, must-revalidate is a good choice for the manifest file itself. Oh, while we’re on the subject…

现在我想我必须对我服务器上的所有文件启用 no-cache headers 并且只依赖于应用程序缓存,但是

  1. 如何在我的本地 intellij 网络服务器中启用 no-cache headers?

答案:intellij 无法从其内置服务器禁用客户端缓存,但您可以从 chrome 禁用客户端缓存:Disabling Chrome cache for website development

  1. 如何使用 jetty-runner 在我的服务器中启用 no-cache headers?

回答:根据this,你应该修改webdefault.xml

<!--
<init-param>
      <param-name>cacheControl</param-name>
      <param-value>no-cache,public</param-value>
</init-param>
-->

但将其放入您的 web.xml 文件更容易:

<servlet>
  <servlet-name>default</servlet-name>
  <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class>
  <init-param>
    <param-name>cacheControl</param-name>
    <param-value>no-cache,public</param-value>
  </init-param>
</servlet>