我们有一个使用 Sencha cmd 5.0.1.231 构建的 ExtJS 5.01 应用程序。
我们面临的问题是浏览器似乎缓存了我们应用程序的旧版本。在为我们的应用程序提供服务时查看 chrome 上的网络流量时,我可以看到 app.js、app.css 文件都附加了 ?_dc={timestamp} 。现在,这告诉我每次发布我的应用程序的新版本(更新此时间戳)时,浏览器都应该获得一个新版本。但似乎有时仍会提供旧版本。
还有什么我需要做的胸围缓存吗?
谢谢
我们有一个使用 Sencha cmd 5.0.1.231 构建的 ExtJS 5.01 应用程序。
我们面临的问题是浏览器似乎缓存了我们应用程序的旧版本。在为我们的应用程序提供服务时查看 chrome 上的网络流量时,我可以看到 app.js、app.css 文件都附加了 ?_dc={timestamp} 。现在,这告诉我每次发布我的应用程序的新版本(更新此时间戳)时,浏览器都应该获得一个新版本。但似乎有时仍会提供旧版本。
还有什么我需要做的胸围缓存吗?
谢谢
我不明白为什么“有时”浏览器会缓存您的文件,即使默认情况下禁用缓存也是如此。我什至尽可能强制框架使用缓存,方法是将这种和平的代码放在我的app.js
:
Ext.Loader.setConfig({
enabled: true,
disableCaching: false
});
在开发过程中,我打开我的 DevTools 并设置Disable cache (while DevTools is open)
. 这将不允许 Chrome 缓存文件。
但这可能是app.json
您通过设置"update"
或强制“缓存”到本地存储中"appcache"
。检查您的 localstorage 和您的 app.json 以进行验证。
在app.json 中将app.js 的更新属性设置为 full :
{
// Path to file. If the file is local this must be a relative path from this app.json file.
"path": "app.js",
"bundle": true, /* Indicates that all class dependencies are concatenated into this file when build */
// If 'update' not specified, this file will only be loaded once, and cached inside
// localStorage until this value is changed. You can specify:
// - "delta" to enable over-the-air delta update for this file
// - "full" means full update will be made when this file changes
"update": "full"
}
禁用 extjs 中的缓存,以便浏览器从服务器获取数据。为此,请添加以下app.json文件。
"production": {
"cache": {
"enable": false
}
}
"css": [
{
// this entry uses an ant variable that is the calculated
// value of the generated output css file for the app,
// defined in .sencha/app/defaults.properties
"path": "${build.out.css.path}",
"bundle": true,
"update": "full"
}
],