HTML5应用程序缓存 - 即使清单更新,缓存文件也不会更新 [英] HTML5 application cache - cached files do not update, even when manifest is updated

查看:181
本文介绍了HTML5应用程序缓存 - 即使清单更新,缓存文件也不会更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个版本化缓存清单:

I have a versioned cache manifest:

#version = e5b4271

每次此版本更改时,我的webapp都会加载新清单,但从不从服务器加载更新文件。即使我清除了浏览器缓存(不是应用程序缓存本身),或者按Ctrl + Shift + R强制它获取新版本,它仍会从旧的appcache加载文件。

Every time this version changes, my webapp loads the new manifest, but it never loads update files from the server. Even when I clear the browser cache (not the application cache itself), or hit Ctrl+Shift+R to force it to fetch a new version, it still loads the files from the old appcache.

我可以让它更新的唯一方法是在设置中清除浏览器的应用程序缓存,但显然这是不可接受的,因为我需要它为普通用户更新。

The only way I can get it to update is to clear the browser's application cache in settings, but obviously this is unacceptable because I need it to update for regular users.

为什么会发生这种情况的任何想法?

Any ideas why this would happen?

推荐答案

刚想通了。我正在使用Flask的开发服务器,默认情况下(通过werkzeug)它会为静态文件发送12小时的缓存标头。将以下内容添加到我的烧瓶配置中解决了这个问题:

Just figured it out. I'm using Flask's development server, and it seems by default (via werkzeug) it sends cache headers for 12 hours for static files. Adding the following to my flask config solved this:

SEND_FILE_MAX_AGE_DEFAULT = -1

如果其他人有此问题,请检查您的服务器配置以确保不使用静态文件发送缓存头。您可以在首次加载文件时在chrome的网络选项卡中查看此内容。

If anyone else has this issue, check your server config to make sure cache headers are not sent with static files. You can check this in the network tab in chrome during the first load of the file.

这篇关于HTML5应用程序缓存 - 即使清单更新,缓存文件也不会更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆