开发者

Override Output Caching duration for Client caching

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(HttpCa开发者_C百科cheability.Public);

but this value is overridden by the Output Caching profile value. How can i override the value set by the Output Caching profile


I did not test this, but it may help you: as anir writes here:

The headers for the HttpCachePolicy are added by asp.net after the caching module runs and so are not part of the response that is cached. If you want the headers to be cached, just use HttpResponse.SetHeader/AddHeader etc in your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜