调试extjs应用程序时,Chrome浏览器不缓存js文件

时间:2014-11-26 07:31:52

标签: extjs extjs5

到目前为止我能够设置



'disableCaching: false' 




在Ext.Loader.config(在app.js中)并在chrome浏览器上调试extjs应用程序。 但现在,在检查源代码时,我发现文件有filename.js?dc = 1123123,每次从远程获取文件而不是缓存。所以我无法在浏览器上设置断点和调试运行时。 请注意,这种情况是我刷新浏览器的时间。

请告诉我如何解决这个问题。

4 个答案:

答案 0 :(得分:3)

false之前app.jsdisableCacheing设置为Ext.application({...

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

这将从正在获取文件的请求中删除_dc缓存参数。

要在XHR上禁用_dc Ext.Ajax请求使用

Ext.Ajax.disableCaching = false;

与服务器进行代理通信时,noCache类使用Ext.data.proxy.Server属性。

noCache: true

您还可以在 app.json 文件中设置缓存配置。

"loader": {
    // This property controls how the loader manages caching for requests:
    //
    //   - true: allows requests to receive cached responses
    //   - false: disable cached responses by adding a random "cache buster"
    //   - other: a string (such as the build.timestamp shown here) to allow
    //     requests to be cached for this build.
    //
    "cache": "${build.timestamp}",

    // When "cache" is not true, this value is the request parameter used
    // to control caching.
    //
    "cacheParam": "_dc"
}

此外,如果使用Chrome开发工具进行调试,请查看“投放网络”标签上的disableCache,如果使用FF,请使用 CTRL + F5 F5 输入{{ 3}}页面

答案 1 :(得分:0)

设置Ext.Loader配置是一回事。还有一些名为Ext.Boot的东西,在加载器启动并运行之前使用。 Boot有自己的disableCaching设置。默认为这样:

disableCaching: (/[?&](?:cache|disableCacheBuster)\b/i.test(location.search) ||
    !(/http[s]?\:/i.test(location.href)) ||
    /(^|[ ;])ext-cache=1/.test(doc.cookie)) ? false :
    true,

可能会在Boot加载附加到网址的带有dc的文件。如果要永久禁用它,只需替换此代码并将其设置为false

答案 2 :(得分:0)

?cache=false添加到您网址的末尾,以暂时禁用每个请求的缓存。

答案 3 :(得分:0)

app.json:

"loader": {"cache": true},

然后:

sencha app refresh

它可能看起来令人困惑,但_dc参数然后再也不存在了 -