1

I'm trying to improve the performance of an ASP.NET MVC website. In the process, I ran the PageSpeed Insights tool by Google. This tool mentioned that I should leverage browser caching by setting an expiry date or a maximum age in the HTTP headers for the static resources.

Everything I find online points out configuration settings in IIS. My challenge is, this site is a Microsoft Azure Website. For that reason, I do not have access to IIS to tinker with this stuff.

Is there a way for me to add expiry dates to the HTTP headers for my static resources in this kind of app? If so, how?

Thank you!

user3284007
  • 1,697
  • 7
  • 27
  • 43
  • Is there a possibility to host static assets (images, css, js files) in blob storage instead of along with website? Blob storage allows you to set cache-control header on items which may be useful in your scenario. – Gaurav Mantri Apr 17 '14 at 02:52

1 Answers1

2
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
    {
        requestContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.Public);
        requestContext.HttpContext.Response.Cache.SetMaxAge(TimeSpan.FromSeconds(3600));
        requestContext.HttpContext.Response.Cache.SetExpires(DateTime.UtcNow.AddSeconds(3600));
        base.Initialize(requestContext);
    }