一旦HTML文档有一个清单

一旦HTML文档有一个清单

本文介绍了一旦HTML文档有一个清单(cache.manifest),你怎么能删除它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎一旦你有一个清单条目,la:

It seems that once you have a manifest entry, a la:

<html manifest="cache.manifest">

然后该页面(缓存中的主条目)将始终被缓存(至少通过Safari)直到用户执行删除缓存的操作,即使您稍后从html标记中删除清单属性并更新清单(通过更改其中的内容),也会强制主条目与其他所有内容一起重新加载。

Then that page (the master entry in the cache) will always be cached (at least by Safari) until the user does something to remove the cache, even if you later remove the manifest attribute from the html tag and update the manifest (by changing something within it), forcing the master entry to be reloaded along with everything else.

换句话说,如果你有:


  • index.html(已定义清单)

  • file1.js(在清单中引用)

  • file2.js(在清单中引用)

  • 缓存。 manifest(列出两个js
    文件)

  • index.html (with manifest defined)
  • file1.js (referenced in manifest)
  • file2.js (referenced in manifest)
  • cache.manifest (lists the two jsfiles)

- 从index.html中删除清单条目并修改清单(所以它被浏览器过期并重新加载所有内容)不会阻止此页面表现得好像它仍然完全缓存一样。如果您在index.html上查看源代码,您将不再看到列出的清单,但浏览器仍将仅请求cache.manifest文件,除非该文件的内容已更改,否则不会对任何文件进行任何其他更改。用户。

-- removing the manifest entry from index.html and modifying the manifest (so it gets expired by the browser and all content reloaded) will not stop this page from behaving as if it's still fully cached. If you view source on index.html you won't see the manifest listed anymore, but the browser will still request only the cache.manifest file, and unless that file's content is changed, no other changes to any files will be shown to the user.

这似乎是一个非常明显的错误,它出现在iOS和Mac版本的Safari上。有没有人找到一种方法来重置页面并摆脱缓存而无需用户干预?

It seems like a pretty glaring bug, and it's present on iOS as well as Mac versions of Safari. Has anyone found a way of resetting the page and getting rid of the cache without requiring user intervention?

推荐答案

我一直在研究问题,它似乎不是一个api:

Ive been researching the same question, and it doesnt appear to be an api to:


  1. 动态触发页面缓存

  2. 动态地导致页面停止缓存。

以下是我找到的最佳资源:

Here are the best resources I have found:

特别是这个引自第一个链接:

In particular, this quote from the first link:

否则,任何地方都没有提及卸载缓存。

Otherwise, there is no mention anywhere about unloading the cache.

似乎暗示您无法强制执行错误以使其无法缓存。但是,如下所述,规范建议如果在下载清单文件时发生错误,整个缓存将被删除。

Seems to suggest that you cant force an error to get it to uncache. However, as noted below, the spec suggests that if an error occurs while downloading the manifest file, the entire cache will be removed.

在谷歌浏览器中,用户可以去到以下网址:

In google chrome, the user can go to the following URL:

它似乎建议删除缓存的情况。具体来说,第5.6.4.5节:

It seems to suggest a situation where the cache is removed. Specifically, section 5.6.4.5:

然后说:

基本上,如果对缓存清单文件的请求导致404,则应丢弃整个缓存。那么,您是否尝试过在请求缓存清单文件时服务器返回404或410?这应该工作。诀窍是只返回要从中删除清单的页面的404/410(可能使用url参数?)。

Basically, if the request for the cache manifest file results in a 404, then the entire cache should be discarded. So, have you tried to have the server return a 404 or 410 when the cache manifest file is requested? That should work. The trick is to only return the 404 / 410 for the pages you want to remove the manifest from (perhaps using url parameters?).

这篇关于一旦HTML文档有一个清单(cache.manifest),你怎么能删除它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 23:33