Reputation: 365
I use a Masterpage (asp.net webforms) on my site and I woluld like to implement caching of some static files, like javascript, css etc.
I've tried adding the following to my page_load (in the masterpage) but when I use Fiddler the static files are still under "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));
}
What am i doing wrong here?
// Nicke
Upvotes: 0
Views: 829
Reputation: 31270
Static files are not processed by ASP.NET pipeline unless asked to do so. You don't want to process the static files by it anyway, not for the cache for sure. The IIS does the caching and it would do a better job of it. Configure it in the IIS.
Upvotes: 2