0

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.