Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure-hosted ASP.NET MVC site drops client cache-related HTTP headers

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

like image 592
wolfyuk Avatar asked Jul 23 '13 16:07

wolfyuk


1 Answers

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.

like image 154
Roman Pushkin Avatar answered Oct 16 '22 14:10

Roman Pushkin