2011-03-15 48 views
0

我的網站上使用母版(asp.net web表單),我喜歡woluld實現一些靜態文件緩存,如JavaScript,CSS等如何實現的靜態文件緩存在asp.net

我已經嘗試將以下內容添加到我的page_load(在masterpage中),但是當我使用Fiddler時,靜態文件仍在「no-cache」之下。

protected void Page_Load(object sender, EventArgs e) 
{ 
    // Set cache for 1 hour on all computers and servers. 
    // ... Proxies, browsers, and your server will cache it. 
    Response.Cache.SetCacheability(HttpCacheability.Public); 
    Response.Cache.SetMaxAge(new TimeSpan(1, 0, 0)); 
} 

我在做什麼錯在這裏?除非要求這樣做

// Nicke

回答

2

靜態文件不是由ASP.NET管道處理。你不想通過它來處理靜態文件,而不是肯定的緩存。 IIS進行緩存,它會做得更好。在IIS中進行配置。