ExtJS 6 app.js 在新产品发布后不更新
ExtJS 6 app.js does not updates after new production release
我们正在使用 Extjs 6 并且我们正在使用 sencha cmd
来构建我们的应用程序。
我们面临一个问题。每次我们发布应用程序的生产版本(如 6.3 到 6.4)时,捆绑的 app.js
不会更新,浏览器会从 (from disk cache)
获取该文件。所以每次我们都必须告诉我们的用户,请在获得新版本后清除浏览器的缓存。 That's annoying
.
这是我的 app.json 文件。
"output": {
"base": "${workspace.build.dir}/${build.environment}/${app.name}",
"page": "index.html",
"manifest": "${build.id}.json",
"js": "${build.id}/.js",
"appCache": {
"enable": false,
"update": "full"
},
"resources": {
"path": "${build.id}/resources",
"shared": "resources"
}
},
"production": {
"output": {
"appCache": {
"enable": false,
"path": "cache.appcache"
}
},
......
"cache": {
"enable": false
}
...
这里有两个选项可以解决您的问题:
自定义 app.js 文件名
{
"production": {
"output": {
"js": "${build.id}/app_${build.timestamp}.js"
},
"cache": {
"enable": true
},
"js": [
{
"path": "${build.id}/app.js",
"bundle": true,
"includeInBundle": false
}
],
"output": {
"base": "${workspace.build.dir}/${build.environment}/${app.name}",
"page": "index.html",
"manifest": "${build.id}.json",
"js": "${build.id}/app_${app.version}.js",
"appCache": {
"enable": false,
"update": "full"
},
"resources": {
"path": "${build.id}/resources",
"shared": "resources"
}
}
}
有了这个,每次构建应用程序时,您都会获得 app.js
的新文件名。
添加静态缓存参数
{
"production": {
"loader": {
"cache": "${build.timestamp}"
},
"cache": {
"enable": true
}
}
}
使用此解决方案,ExtJs 将向 app.js
请求附加一个 ?_dc=12345678
参数。此参数在您的下一次构建之前保持不变。
我找到了解决方案:
"js": [
{
"path": "app.js",
"bundle": true,
"includeInBundle": false
}
],
.....
"output": {
"base": "${workspace.build.dir}/${build.environment}/${app.name}",
"page": "index.html",
"manifest": "${build.id}.json",
"js": "${build.id}/app_${app.version}.js",
"appCache": {
"enable": false,
"update": "full"
},
"resources": {
"path": "${build.id}/resources",
"shared": "resources"
}
},
....
这将不会在生产构建中包含 app.js
文件,并创建新的 app.js
文件,最后附加版本,如:app_6.4.js
。
我们正在使用 Extjs 6 并且我们正在使用 sencha cmd
来构建我们的应用程序。
我们面临一个问题。每次我们发布应用程序的生产版本(如 6.3 到 6.4)时,捆绑的 app.js
不会更新,浏览器会从 (from disk cache)
获取该文件。所以每次我们都必须告诉我们的用户,请在获得新版本后清除浏览器的缓存。 That's annoying
.
这是我的 app.json 文件。
"output": {
"base": "${workspace.build.dir}/${build.environment}/${app.name}",
"page": "index.html",
"manifest": "${build.id}.json",
"js": "${build.id}/.js",
"appCache": {
"enable": false,
"update": "full"
},
"resources": {
"path": "${build.id}/resources",
"shared": "resources"
}
},
"production": {
"output": {
"appCache": {
"enable": false,
"path": "cache.appcache"
}
},
......
"cache": {
"enable": false
}
...
这里有两个选项可以解决您的问题:
自定义 app.js 文件名
{
"production": {
"output": {
"js": "${build.id}/app_${build.timestamp}.js"
},
"cache": {
"enable": true
},
"js": [
{
"path": "${build.id}/app.js",
"bundle": true,
"includeInBundle": false
}
],
"output": {
"base": "${workspace.build.dir}/${build.environment}/${app.name}",
"page": "index.html",
"manifest": "${build.id}.json",
"js": "${build.id}/app_${app.version}.js",
"appCache": {
"enable": false,
"update": "full"
},
"resources": {
"path": "${build.id}/resources",
"shared": "resources"
}
}
}
有了这个,每次构建应用程序时,您都会获得 app.js
的新文件名。
添加静态缓存参数
{
"production": {
"loader": {
"cache": "${build.timestamp}"
},
"cache": {
"enable": true
}
}
}
使用此解决方案,ExtJs 将向 app.js
请求附加一个 ?_dc=12345678
参数。此参数在您的下一次构建之前保持不变。
我找到了解决方案:
"js": [
{
"path": "app.js",
"bundle": true,
"includeInBundle": false
}
],
.....
"output": {
"base": "${workspace.build.dir}/${build.environment}/${app.name}",
"page": "index.html",
"manifest": "${build.id}.json",
"js": "${build.id}/app_${app.version}.js",
"appCache": {
"enable": false,
"update": "full"
},
"resources": {
"path": "${build.id}/resources",
"shared": "resources"
}
},
....
这将不会在生产构建中包含 app.js
文件,并创建新的 app.js
文件,最后附加版本,如:app_6.4.js
。