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

6
  • I have this exact same issue. Setting the headers (e.g Response.Cache.SetExpires) works locally, but gets stripped off when deployed... Commented Nov 4, 2013 at 20:26
  • I'm not sure but according to this msdn article 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.' Commented Mar 15, 2014 at 1: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)? Commented Apr 15, 2014 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? Commented Nov 11, 2014 at 15:42
  • @WolfyUK - Did you ever resolve this? Commented Mar 8, 2015 at 21:21

2 Answers 2

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.

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

Comments

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.

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.