gpt4 book ai didi

javascript - 缓存 list 缓存所有文件

转载 作者:行者123 更新时间:2023-12-03 11:04:32 25 4
gpt4 key购买 nike

我在 HTML 5 中遇到 list 缓存问题。这是我的 list 文件:

CACHE MANIFEST
# This manifest was generated by grunt-manifest HTML5 Cache Manifest Generator
# Time: Tue Jan 13 2015 15:05:00 GMT+0100 (Central European Standard Time)

CACHE:
js/application.js
js/pdf.js
js/vendor.js
js/vendor/jquery.min.js

NETWORK:
*

SETTINGS:
prefer-online

我只想缓存manifest.appcache中“cache”部分中的文件。所有其他文件(例如 ajax 请求)不应由浏览器缓存。

现在,当我刷新网站时,Everythink 都会从缓存中加载。

Cache chrome

我做错了什么?

最佳答案

将您的 js 文件放在 CACHE 指令之外以显式缓存它们。

CACHE MANIFEST
# Tue Jan 13 2015 15:05:00 GMT+0100 (Central European Standard Time)

# Explicitly cached entries
js/application.js
js/pdf.js
js/vendor.js
js/vendor/jquery.min.js

# offline.html will be displayed if the user is offline
FALLBACK:
# offline.html

# All other resources (e.g. sites) require the user to be online.
NETWORK:
*

# Additional resources to cache
CACHE:
# ...

Template taken from A Beginner's Guide to Using the Application Cache

每个资源还将有一个包含 list 指令的主条目:

这些是添加到缓存中的资源,因为用户访问的浏览上下文包含一个文档,该文档使用其 list 属性 ( Using the application cache ) 指示它位于此缓存中。

还有一个用于 list 文件本身。

您可能看到的所有其他被缓存的内容都与 list 文件无关,而是与资源的正常浏览器缓存有关,您可以使用已知的缓存清除技术(例如添加到资源 URL 的随机参数)来清除这些资源。

Here is a good SO post on preventing caching of ajax resources

关于javascript - 缓存 list 缓存所有文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27924557/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com