2011-01-07 71 views

回答

1

如果您.LESS文件都位於同一個文件夾,你可以指定static content一個額外web.config在這個特定的文件夾httpExpires屬性:

<system.webServer> 
    <staticContent> 
     <clientCache 
      httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" 
      cacheControlMode="UseExpires" /> 
    </staticContent> 
</system.webServer> 

或者在你的根添加相同的部分web.config和定義位置路徑包含該文件夾中的文件.LESS:

<location path="YourLessFilesFolder"> 
    <system.webServer> 
     <staticContent> 
      <clientCache 
       httpExpires="Sun, 29 Mar 2020 00:00:00 GMT" 
       cacheControlMode="UseExpires" /> 
     </staticContent> 
    </system.webServer> 
</location> 

您還需要到.LESS文件添加到靜態內容類型的集合(see)。我不知道的MIME類型,但你的想法:

<system.webServer> 
    <staticContent> 
     <mimeMap fileExtension=".less" mimeType="text/css" /> 
    </staticContent> 
</system.webServer> 
+0

我已經在這個答案添加的緩存,以所有靜態內容`\t \t` \t \t \t \t \t`但是目前我們在已經使用過的瀏覽器中面對js沒有更新的問題 – Eldho 2016-09-09 15:07:19

1

小心設置httpExpires日期,我也不會超過一年使用更高的價值。您無法替換來自代理服務器和客戶端的緩存文件,直到到達日期爲止。以你20年的榜樣!

使用緩存驗證而不是過期保存。

或使用:

<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="1.00:00:00" /> 

到一天的緩存文件。

更多信息here

相關問題