1

我们正在使用 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 
        }
...
4

2 回答 2

3

这里有两个选项可以解决您的问题:

自定义 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 将在请求中附加一个?_dc=12345678参数。app.js在您下一次构建之前,此参数保持不变。

于 2017-06-13T13:42:41.790 回答
2

我找到了解决方案:

"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.

于 2017-06-14T06:09:07.027 回答