I'm trying to enable client js caching for a asp.net mvc bundle added to an external site. Currently the site references the js bundle by using url https://example.com/bundles/myscriptbundle.
Looking at the response from the server I always seem to get Cache-Control:"no-cache".
I tried adding the following to the global.asax.cs but it doesn't seem to make a difference. Any suggestions how to add cache headers to bundle?
protected void Application_EndRequest(object sender, EventArgs e)
{
var request = this.Request;
var response = this.Response;
if (request.RawUrl.Contains("bundles/"))
{
response.Cache.SetCacheability(HttpCacheability.Public);
response.Cache.SetMaxAge(new TimeSpan(365,0,0,0));
response.Cache.SetSlidingExpiration(true);
}
Turns out it was a version of the optimization dll. Check this answer for details