使用HTML5缓存时无法加载外部资源

External resources fail to load when using HTML5 cache

本文关键字:加载 外部 资源 HTML5 缓存 使用      更新时间:2023-09-26

我正在尝试让应用程序缓存工作:

CACHE MANIFEST
/css/style.css
/js/colors.js
/js/dropzone.js
/js/jquery.min.js
/js/script.js
/img/icon_analytics.png
/img/icon_exit.png
/img/icon_expand.png
/img/icon_list.png
/img/icon_lock.png
/img/icon_menu.png
/img/icon_more_content.png
/img/icon_settings.png
/img/icon_settings_black.png
/img/svg_icons/close_fullscreen.svg
/img/svg_icons/go_fullscreen.svg
/img/loader.gif

但我在控制台上得到的是:

GET https://www.google.com/jsapi net::ERR_FAILED
(index):517 Uncaught ReferenceError: google is not defined
(index):524 GET http://www.google-analytics.com/analytics.js net::ERR_FAILED
0.s3.envato.com/files/115114837/profile.jpg:1 GET https://0.s3.envato.com/files/115114837/profile.jpg net::ERR_FAILED
jquery.min.js:3 GET http://fonts.gstatic.com/s/roboto/v15/mnpfi9pxYH-Go5UiibESIpBw1xU1rKptJj_0jans920.woff2 net::ERR_FAILED

显然,它拒绝加载.appcache文件中未指定的任何资源。我甚至试图只指定图像,但它仍然会为样式表和所有.js文件抛出错误。

怎么回事?

您需要添加NETWORK部分,如下所示:

CACHE MANIFEST
CACHE:
/css/style.css
/js/colors.js
/js/dropzone.js
/js/jquery.min.js
/js/script.js
/img/icon_analytics.png
/img/icon_exit.png
/img/icon_expand.png
/img/icon_list.png
/img/icon_lock.png
/img/icon_menu.png
/img/icon_more_content.png
/img/icon_settings.png
/img/icon_settings_black.png
/img/svg_icons/close_fullscreen.svg
/img/svg_icons/go_fullscreen.svg
/img/loader.gif
NETWORK:
*

点击此处阅读更多信息。