admin管理员组

文章数量:1336197

We have a ExtJS 5.01 app built with Sencha cmd 5.0.1.231.

The issue we are facing is that browsers seem to cache the old version of our application. On looking at the network traffic on chrome when our application is served, i can see that app.js, app.css files all have ?_dc={timestamp} appended to them. Now, that tells me that every time a new version of my app is released (which updates this timestamp), the browsers should get a new version. But it seems like sometimes still the old version get served.

Is there anything else i need to do bust cache?

Thanks

We have a ExtJS 5.01 app built with Sencha cmd 5.0.1.231.

The issue we are facing is that browsers seem to cache the old version of our application. On looking at the network traffic on chrome when our application is served, i can see that app.js, app.css files all have ?_dc={timestamp} appended to them. Now, that tells me that every time a new version of my app is released (which updates this timestamp), the browsers should get a new version. But it seems like sometimes still the old version get served.

Is there anything else i need to do bust cache?

Thanks

Share Improve this question edited Oct 15, 2015 at 19:38 Tarabass 3,1502 gold badges19 silver badges35 bronze badges asked Oct 15, 2015 at 5:14 playerplayer 6106 silver badges15 bronze badges 3
  • Actually it should work. Does this problem occur only for some specific js's or for all? Have you this issue in production or in development environment? – yorlin Commented Oct 15, 2015 at 6:31
  • The timestamp is for the request - each request should have a new timestamp (though if you've got a batch going at the same time, it might be the same). The purpose of the cache-busting parameter is to force caches - such as proxy servers - to get a new version. Some cache servers don't respect that, though. The fact that you're seeing a network request, though, means that the browser at least is trying to get a new version... – Robert Watkins Commented Oct 15, 2015 at 8:58
  • @yorlin seems to happen in production environment. Development is not a problem because i always have developer toolbar open in chrome which i think disables caching – player Commented Oct 15, 2015 at 20:36
Add a ment  | 

2 Answers 2

Reset to default 2

Set the update property for app.js to full in app.json:

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

Disable the cache in extjs so browser will get data from server. To do that, add the following app.json file.

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

I don't get it why "sometimes" the browser is caching your files, even when caching is disabled by default. I even force the framework to use cache whenever possible, by putting this peace of code in my app.js:

Ext.Loader.setConfig({
    enabled: true,
    disableCaching: false
});

While developing I open up my DevTools and set Disable cache (while DevTools is open). This will not allow Chrome to cache files.

But it could be that in your app.json you are forcing "caching" into your local storage by setting "update" or "appcache". Check your localstorage and your app.json to verify.

本文标签: javascriptDisable caching for ExtJs appStack Overflow