HTML5 清单缓存问题
我正在尝试缓存(以供离线使用)我的 webb 应用程序的某些部分,但每当我缓存 css 文件或 js 文件时,从缓存加载时它们都会变成空(在 Safari 和 Firefox 中检查)
什么会导致此问题?我已确保清单文件正常工作,并且我已尝试使用相对路径和绝对路径(包括页面域)。
如果我排除所有脚本和 css 文件,它们加载得很好,但是一旦我将它们放入脱机缓存中,它们就会作为空文件加载。
其他离线应用程序在我测试过的平台上运行良好,因此我的设置一定有问题。如果这对事情有任何影响,这些页面将由运行在 Linux 上的 apache 服务器提供服务。
css 文件请求的标头:
Date Tue, 12 Jan 2010 11:06:41 GMT
Server Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.4 with Suhosin-Patch
Last-Modified Thu, 15 Oct 2009 11:53:16 GMT
Etag "36625c-1da0-475f7ecbca300"
Accept-Ranges bytes
Content-Length 7584
Content-Type text/css
当然这是没有启用离线缓存的情况。
I'm trying to cache (for offline use) some parts of my webbapplication but whenever I cache css files or js files they turn up empty when loaded from the cache (checked both in Safari and Firefox)
What can cause this problem? I have made sure that the manifest file is working properly and I have tried both with relative paths and absolute paths including the domain of the page.
If I exclude all scripts and css files they load just fine but as soon as I put them in the offline cache they get loaded as empty files.
Other offline applications work fine on the platforms I have tested this on so there must be a problem with my setup. The pages get served with an apache server running on linux if this has any effect on things.
Header of request for css file:
Date Tue, 12 Jan 2010 11:06:41 GMT
Server Apache/2.2.11 (Ubuntu) PHP/5.2.6-3ubuntu4.4 with Suhosin-Patch
Last-Modified Thu, 15 Oct 2009 11:53:16 GMT
Etag "36625c-1da0-475f7ecbca300"
Accept-Ranges bytes
Content-Length 7584
Content-Type text/css
This is without the offline cache enabled of course.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发布 CSS 文件的响应标头。最可能的原因是文件即将过期。
有 Etag 但没有 Expires 或缓存控制标头似乎有点奇怪。它可能会混淆离线缓存。尝试在您的服务器配置(Apache 的 ExpiresDefault)中显式设置文档过期规则。
Etag 的规则规定,如果 Etag 与后续请求匹配,服务器(在本例中为离线缓存)应发送 304(使用您已有的内容)和 NO DATA。但是,如果该文档不在浏览器的正常缓存中,并且您处于离线状态,则无法从中检索原始文档。
Post your response headers for a CSS file. The most likely reason is that the files are expiring.
Seems a little odd to have an Etag but not an Expires or cache-control header. It may be confusing the offline cache. Try explicitly setting a document expiry rule in your server configuration, ExpiresDefault for Apache.
The rules for Etag say if the Etag matches on a subsequent request the server (in this case your offline cache) should send a 304 (use what you already have) and NO DATA. However, if the document isn't in the browsers NORMAL cache and you are offline there is nowhere to retreive the original document from.