2015-10-15 197 views
3

我們有一個使用Sencha cmd 5.0.1.231構建的ExtJS 5.01應用程序。爲ExtJs應用程序禁用緩存

我們面臨的問題是瀏覽器似乎緩存我們應用程序的舊版本。在我們的應用程序提供服務時,在查看chrome上的網絡流量時,我可以看到app.js,app.css文件都附加了?_dc = {timestamp}。現在,這告訴我,每當我的應用程序的新版本發佈(更新此時間戳),瀏覽器應該得到一個新版本。但它似乎有時仍然是舊版本的服務。

還有什麼我需要做胸部緩存嗎?

感謝

+0

其實它應該工作。這個問題是否僅出現在某些特定的js或所有人身上?你在生產或開發環境中遇到這個問題嗎? – yorlin

+0

時間戳記是針對請求的 - 每個請求應該有一個新的時間戳記(儘管如果你有一個批次同時進行,它可能是相同的)。 cache-busting參數的用途是強制高速緩存(如代理服務器)獲取新版本。不過,有些緩存服務器並不尊重這一點。 儘管您看到網絡請求,但意味着瀏覽器至少正在嘗試獲取新版本... –

+0

@yorlin似乎在生產環境中發生。開發不是問題,因爲我總是有開發工具欄打開鉻我認爲禁用緩存 – player

回答

1

爲什麼「有時」瀏覽器緩存文件我不明白這一點,即使在高速緩存默認情況下禁用。我甚至強迫框架使用緩存只要有可能,通過把這個代碼和平我app.js

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

在開發我打開DevTools並設置Disable cache (while DevTools is open)。這將不允許Chrome緩存文件。

但它可能是在您的app.json中,通過設置"update""appcache"強制「緩存」到本地存儲中。檢查你的localstorage和你的app.json來驗證。

+0

謝謝..在我的app.json我有appcache:{「緩存」:[「index.html」]}。你認爲這會導致緩存問題嗎? – player

+0

我建議你生成一個測試應用程序,並將其與已有的應用程序進行比較。開箱即用,它不應該給你任何問題,只有當你做出改變時。 – Tarabass

0

設置app.js更新屬性,以充滿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" 
} 

禁用緩存ExtJS的瀏覽器,以便從服務器獲取數據。爲此,請添加以下app.json文件。

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

請參閱https://stackoverflow.com/a/44536748/2935802 – Sudhakar