HTML5   发布时间:2022-04-26  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了我的HTML5应用程序缓存清单正在缓存所有内容大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
更新:

**我发布了这个问题,当这个功能真的是新的,我现在意识到这个功能不应该这样使用,除非它通过JavaScript使用。但是似乎这个黑客对于大多数初学者来说是一个很好的解决方案,他们犯同样的错误和滥用这个功能。如果你想缓存除HTML之外的所有内容,这应该是用JS完成的,或者你可以使用下面的解决方**

我想我的问题归结为:
如果使用HTML标签的manifest属性引用清单的文件位于MASTER CACHE ENTRIES下,如何使用动态页面使用清单。

我的文件看起来像这样

CACHE MANIFEST

CACHE:
# IMAGES:
/stylesheets/bg.jpg
/stylesheets/conT_Bg.png
#and so forth.. 

#EXTERNAL
http://chat.mydomain.com/themes/images/panel_bg.png
http://chat.mydomain.com/themes/images/images_core.png

####################################
#STYLE SHEETS:
/stylesheets/min.css
/stylesheets/css_night.aspx

#####################################
#JAVASCRIPT:
/JAVASCRIPT/header_javascript.js

#EXTERNAL:
http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js
http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js

falLBACK:
/ /offline.PHP

NETWORK:
*

现在的问题是,一旦我浏览不在清单中的页面,我的实际的动态PHP文件像index.PHP,当我第一次看到页面,那里没有缓存chrome去:

Adding master entry to Application Cache with manifest http://208.109.248.197/manifest.appcache

Application Cache Downloading event
Application Cache Progress event (0 of 28) 
...
Application Cache Progress event (28 of 28) 
Application Cache Noupdate event

到目前为止这么好,直到我实际加载一个页面,并且chrome进行:

Application Cache updateReady event
Adding master entry to Application Cache with manifest http://mydomain.com/manifest.appcache

现在,您可以在最后一行看到它将index.PHP添加到我的应用程序缓存中,我已经通过访问url验证了这一点:chrome:// appcache-internals /

它说:

Flags   URL Size (headers and data)
Explicit,http://mydomain/JAVASCRIPT/header_javascript.js 57.5 kB
Master,http://mydomain/home.PHP 51.2 kB
Master,http://mydomain/index.PHP   53.5 kB
Master,fallBACk,http://mydomain/offline.PHP 49.4 kB

像index.PHP和home.PHP这样的东西不应该被缓存。如果可能,我想告诉它不缓存任何html扩展。但这是我从各种RFC中学到的,我相信:
在线白名单通配符标志,打开或阻止。

The open state inDicates that any URL not listed as cached is to be implicitly treated as being in the online whitelist namespaces; the blocking state inDicates that URLs not listed explicitly in the manifest are to be treated as unavailable.

那么我想使用这些在线白名单通配符标志之一,并将其​​设置为阻止,但我没有找到任何更多的解释或示例。
我也读:

zero or more URLs that form the online whitelist namespaces.

these are used as prefix match patterns,and declare URLs for which the user agent will ignore the application cache,instead fetching them normally (i.e. from the network or locale http cache as appropriatE).

我也想使用这样的一些模式,但是再次找不到任何文档。为什么没有appcache清单文档的迹象,没有其他网站,我一直在使用它,因为我的chrome appcache目录显示没有!

感谢您的时间!

解决方法

这是我发现的一个黑客:

没有找到最终的答案,但从我所学到的东西看来,清单并不意味着在每个页面上设置。再次,我不知道,但这是一个我遇到的黑客。我有一个页面,如manifest.html具有

<html manifest="manifest.appcache">

我了解到没有这个的页面将不会添加到缓存中,但是如果在同一个域上仍然继续使用应用程序缓存。因此,如果您将manifest.html包含在一个iframe中的plain html页面,那么它将不会缓存该页面,如chrome将不会再输出

Adding master entry to Application Cache with manifest

但是如果您进入网络选项卡,您将看到它正在使用缓存

<iframe id='manifest_iframe_hack' 
  style='display: none;' 
  src='temporary_manifest_hack.html'>
</iframe>

temporary_manifest_hack.html的内容

<!DOCTYPE HTML>
<html lang="en" class="no-js" manifest="manifest.appcache">
    <head>
        <Meta charset="utf-8">
        <title>Hack 4 Manifest</title>
    </head>
    <body></body>
</html>

大佬总结

以上是大佬教程为你收集整理的我的HTML5应用程序缓存清单正在缓存所有内容全部内容,希望文章能够帮你解决我的HTML5应用程序缓存清单正在缓存所有内容所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。