ASP.NET Cache.SetCacheability(HttpCacheability.Public)未设置头 [英] ASP.NET Cache.SetCacheability(HttpCacheability.Public) not setting header

查看:325
本文介绍了ASP.NET Cache.SetCacheability(HttpCacheability.Public)未设置头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有检索存储在数据库中的图像,并将其写入到响应一个HttpHandler(也做到了这一点作为一个ASPX页面)。我添加了以下行code,试图让图像缓存在浏览器中,但每当我看着萤火虫的反应,它总是有私有缓存控制标头值。

I have an HttpHandler (have also done this as an ASPX page) that retrieves an image stored in the db and writes it out to the response. I have added the following lines to the code to try and get the images to cache in the browser, but whenever I look at the response in Firebug, it always has a cache-control header value of "private".

Response.Cache.SetCacheability(HttpCacheability.Public)

我已经尝试了各种东西,喜欢用Response.ClearHeaders&放大器; Response.AddHeader()来手动添加缓存控制头值,但无济于事。任何想法?

I've tried all sorts of things, like using the Response.ClearHeaders & Response.AddHeader() to manually add the "Cache-Control" header value, but to no avail. Any ideas?

编辑:结果
更多信息:这是一个HTTP处理程序(ashx的)运行,并且我已经测试它都在我的本地IIS 5.1,并在托管网站我认为这是IIS 6


More info: This is running in an HTTP Handler (.ashx), and I have tested it both on my local IIS 5.1, and on the hosting site which I think is IIS 6.

推荐答案

有没有任何机会的页面需要身份验证?运行时会强制缓存控制:私人需要身份验证,以prevent的私人内容被意外缓存上的公共代理页

Does the page by any chance require authentication? The runtime will force Cache-Control: private on pages that require authentication to prevent the accidental caching of private content on public proxies.

您使用卡西尼?如果是这样,它总是迫使缓存控制:私人。如果是这样,你可以尝试切换到IIS来代替。

Are you using Cassini? If so, it always forces Cache-Control: private. If so, you might try switching to IIS instead.

这篇关于ASP.NET Cache.SetCacheability(HttpCacheability.Public)未设置头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆