覆盖客户端缓存的输出缓存持续时间
我有一个基于 REST 的 WCF 服务,它返回 JSON 数据作为响应。为了提高性能,启用输出缓存,位置为任意,持续时间为1 小时。 我希望允许客户端将响应缓存 1 个月,同时将数据在服务器上缓存仅 1 小时,为此,我在代码中添加了以下几行,
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(30));
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public);
但该值是由输出缓存配置文件值覆盖。我如何覆盖输出缓存配置文件设置的值
I have a REST based WCF service which returns JSON data as response. To improve performance Output Caching is enabled with location as ANY and duration 1 hr.
I want to allow clients to cache the response for a period of 1 month while keeping the data cached on the server for only 1 hr, to do this i added the following lines in my code
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(30));
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public);
but this value is overridden by the Output Caching profile value. How can i override the value set by the Output Caching profile
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有对此进行测试,但它可能会对您有所帮助:正如 anir 所写此处:
I did not test this, but it may help you: as anir writes here: