0

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);
    }
NullReference
  • 4,404
  • 12
  • 53
  • 90

1 Answers1

0

Turns out it was a version of the optimization dll. Check this answer for details

MVC4 Script Bundles Caching issue

Community
  • 1
  • 1
NullReference
  • 4,404
  • 12
  • 53
  • 90