客户端缓存从 HTTPHandler 返回的 XML
我有一个返回一些 XML 的 HTTPHandler。我试图弄清楚如何将其缓存在浏览器中,就好像它是一个静态 XML 文件一样。
我已经尝试过这个以及其他一些变体和其他缓存选项,但我所做的一切似乎都无法使其缓存(根据 Fiddler)。
关于如何在客户端浏览器上缓存输出有什么想法吗?
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/xml";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.Cache.SetCacheability(HttpCacheability.Private);
context.Response.Cache.SetMaxAge(new TimeSpan(1, 0, 0));
string sXml = GetTableAsXml();
context.Response.Write(sXml);
}
I have an HTTPHandler that returns some XML. I am trying to figure out how to get this to cache in the browser, as if it were a static XML file.
I've tried this along with a few other variations and other Cache options, but nothing I do seems to make it cache (according to Fiddler).
Any ideas on how I can cache the output on the client's browser?
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/xml";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.Cache.SetCacheability(HttpCacheability.Private);
context.Response.Cache.SetMaxAge(new TimeSpan(1, 0, 0));
string sXml = GetTableAsXml();
context.Response.Write(sXml);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此帖子可能会对您有所帮助。
This thread might help you.