Ale*_*tin 5 safari asp.net-mvc caching http web
我有一个托管在 Azure AppService 上的 ASP.NET MVC 网站,我正在尝试在客户端启用动态图像的缓存(在 Controller#File() 方法的帮助下提供服务)。我使用了一些技术来实现这一点:
将基于查询字符串的 URL 转换为“经典”URL,例如
/file/i/Supplier/Logo/fed88a06-1157-4bbb-826d-365bdd8c89eb/png/cng.png
我正在使用 IIS 重写模块将其转换回基于查询字符串的 URL。
向返回图像的操作方法添加了以下属性:
[OutputCache(Duration = 31536000, Location = System.Web.UI.OutputCacheLocation.ServerAndClient)]
//31536000 seconds represent one year
Run Code Online (Sandbox Code Playgroud)
它适用于除 Safari 10 和 iOS 10 之外的所有网络浏览器。图像在 Sarafi 9、8、7、iOS 8.3.3、Chrome、Edge、Firefox 中缓存得很好,但在 Safari 10 中,它们几乎从未被缓存(在 iOS 上) 10 也是,但这并不重要)。这种情况可以在两台物理 Mac 笔记本电脑以及 BrowserStack 上的 Mac VM 上重现。Safari 中的缓存未禁用。
Apple 最新的 Web 浏览器有什么特别之处,它们没有按预期缓存资源?或者,我做错了什么?
我不知道如何在 Safari 中查看请求和响应标头(有可能吗?)但在 Chrome 中,请求和响应标头如下。
为清楚起见,我删除了 Host、Referrer 和 Cookie 标头。
第一次运行
要求
Accept:image/webp,image/*,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,ru;q=0.6,sr;q=0.4
Cache-Control:no-cache
Connection:keep-alive
DNT:1
Pragma:no-cache
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
Run Code Online (Sandbox Code Playgroud)
回复
Cache-Control:private, max-age=31533495
Content-Length:32300
Content-Type:image/png
Date:Mon, 17 Oct 2016 14:58:59 GMT
Expires:Tue, 17 Oct 2017 14:17:13 GMT
Last-Modified:Mon, 17 Oct 2016 14:17:13 GMT
Vary:*
X-Frame-Options:SAMEORIGIN
Run Code Online (Sandbox Code Playgroud)
第二次运行
要求
Accept:image/webp,image/*,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,ru;q=0.6,sr;q=0.4
Connection:keep-alive
DNT:1
If-Modified-Since:Mon, 17 Oct 2016 14:17:12 GMT
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
Run Code Online (Sandbox Code Playgroud)
回复
Request URL:http://******/file/i/Supplier/Logo/1f70c0ac-309c-4629-9186-6ee1b3700d3e/png/crown-logo.png
Request Method:GET
Status Code:304 Not Modified
Cache-Control:private, max-age=31533237
Date:Mon, 17 Oct 2016 15:03:15 GMT
Expires:Tue, 17 Oct 2017 14:17:12 GMT
Last-Modified:Mon, 17 Oct 2016 14:17:12 GMT
Vary:*
X-Frame-Options:SAMEORIGIN
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1048 次 |
| 最近记录: |