12

We have recently begun moving some of our ASP.NET MVC websites from our own managed environment to Azure. One of the issues we have seen is that client side caching does not seem to be working properly when delivering dynamically created content. Specifically, the cache-related headers added to the HTTP response in code are stripped.

For example, the following headers are returned on the old environment in order to advise the client that the content may be cached:

Cache-Control:          public, max-age=31533144
Content-Disposition:    attachment; filename=picture.png
Content-Length:         64326
Content-Type:           image/png
Date:                   Tue, 23 Jul 2013 15:44:57 GMT
Etag:                   "845D3DD630A7AEF5B68EA7A09B670A4D"
Expires:                Fri, 23 Aug 2013 14:57:22 GMT
Last-Modified:          Tue, 23 Jul 2013 14:57:22 GMT
Server:                 Microsoft-IIS/7.5

But on Azure, the following headers are returned instead:

Content-Disposition:    attachment; filename=picture.png
Content-Length:         64326
Content-Type:           image/png
Date:                   Tue, 23 Jul 2013 15:44:57 GMT
Server:                 Microsoft-IIS/8.0
X-Powered-By:           ARR/2.5, ASP.NET

As you can see, the Cache-Control, Etag, Expires and Last-Modified headers have been dropped.

I have seen a number of suggestions regarding the caching of static content, but I do not believe that these will help in this case. Is it a case that the structure of the Azure CDN prevents caching in this way? Should Azure blobs be used instead? Is there a basic configuration change that may have been overlooked?

Thanks in advance

wolfyuk
  • 746
  • 1
  • 8
  • 26
  • I have this exact same issue. Setting the headers (e.g Response.Cache.SetExpires) works locally, but gets stripped off when deployed... – Gareth Nov 04 '13 at 20:26
  • I'm not sure but according to this msdn article http://msdn.microsoft.com/en-us/library/windowsazure/gg680299.aspx 'If you want to programmatically cache application content, make sure that the content is marked as cacheable by setting HttpCacheability to Public.' – Alexander V. Mar 15 '14 at 01:33
  • 4
    Hey, just so I can understand a little better - are you using Azure Websites or Azure VMs?Also, how are you configuring the HTTP caching? In the web.config, via IIS, programmatically (OutputCache)? – Deano Apr 15 '14 at 10:50
  • Where were settings that add missing tags in previous enviroment? Were they added automaticaly (you didn't set this headers manualy)? By HttpModules? By IIS settings? – Barada Nov 11 '14 at 15:42
  • @WolfyUK - Did you ever resolve this? – Kildareflare Mar 08 '15 at 21:21
  • @Kildareflare - No, sorry, this never got resolved. – wolfyuk Mar 08 '15 at 22:32

2 Answers2

1
X-Powered-By:           ARR/2.5, ASP.NET

ARR stands for Application Request Routing.

Go to inetmgr UI and click on the server name and you will find the option 'Application Request Routing Cache'.

You'll see 'Cache configuration', check options there. Also, check 'Cache control rules' there. Click 'Add rule...' and try play around with it.

Roman Pushkin
  • 5,639
  • 3
  • 40
  • 58
0

Azure Websites site behind ARR. ARR will drop some HTTP headers and add its own, it's not something you have direct control over. A better fit for your problem may be using Azure CDN for static content. This does pay attention to and use the cache control headers. You can run a CDN on top of a blob storage container.

Paul Fryer
  • 9,268
  • 14
  • 61
  • 93