Ronak Patel
Ronak Patel

Reputation: 671

ExtJS 6 app.js does not updates after new production release

We are using Extjs 6 and we are using sencha cmd to build our application.

We are facing one issue. Every time we release production version of our application like 6.3 to 6.4, bundled app.js does not get updated and browser take that file from (from disk cache). So every time we have to tell our users that please clear your browser's cache after you got new release. That's annoying.

This is my app.json file.

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

Upvotes: 1

Views: 2240

Answers (2)

Artem Stepin
Artem Stepin

Reputation: 421

Here are two options to solve your issue:

Customize app.js filename

        {
            "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"
            }

        }
    }

With this, you get every time you build your app an new file name for app.js.

Add static cache parameter

  {
        "production": {
            "loader": {
                "cache": "${build.timestamp}"
            },
            "cache": {
                "enable": true
            }
        }
    }

With this solution ExtJs will append a ?_dc=12345678 parameter to the app.js request. This parameter stays the same until your next build.

Upvotes: 4

Ronak Patel
Ronak Patel

Reputation: 671

I have found solution:

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

This will not include app.js file in production build and create new app.js file with version appended at last to it like: app_6.4.js.

Upvotes: 4

Related Questions