azure托管ASP。NET MVC站点删除与客户缓存相关的HTTP头

时间:2022-09-13 04:02:23

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.

我们最近开始移动一些ASP。NET MVC网站从我们自己的托管环境到Azure。我们已经看到的一个问题是,在交付动态创建的内容时,客户端缓存似乎没有正常工作。具体地说,在代码中添加到HTTP响应的与缓存相关的头信息将被删除。

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:

但是在Azure上,返回以下标题:

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.

如您所见,Cache-Control、Etag、Expires和最后修改的头已经被删除。

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?

我已经看到了一些关于静态内容缓存的建议,但是我不认为这些在这种情况下会有帮助。是否Azure CDN的结构以这种方式阻止缓存?是否应该使用Azure blob ?是否存在可能被忽略的基本配置更改?

Thanks in advance

谢谢提前

2 个解决方案

#1


1  

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

ARR stands for Application Request Routing.

ARR表示应用程序请求路由。

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

转到inetmgr UI并单击服务器名,您将找到“应用程序请求路由缓存”选项。

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

您将看到“缓存配置”,检查选项。另外,检查“缓存控制规则”。点击“添加规则…然后试着玩转它。

#2


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.

Azure网站背后的ARR。ARR会删除一些HTTP头文件并添加它自己的,这不是你可以直接控制的东西。更适合您的问题可能是对静态内容使用Azure CDN。这确实需要注意并使用缓存控制头。您可以在blob存储容器上运行CDN。

#1


1  

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

ARR stands for Application Request Routing.

ARR表示应用程序请求路由。

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

转到inetmgr UI并单击服务器名,您将找到“应用程序请求路由缓存”选项。

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

您将看到“缓存配置”,检查选项。另外,检查“缓存控制规则”。点击“添加规则…然后试着玩转它。

#2


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.

Azure网站背后的ARR。ARR会删除一些HTTP头文件并添加它自己的,这不是你可以直接控制的东西。更适合您的问题可能是对静态内容使用Azure CDN。这确实需要注意并使用缓存控制头。您可以在blob存储容器上运行CDN。