http-caching

Output caching for an ApiController (MVC4 Web API)

三世轮回 提交于 2019-11-26 19:33:34
问题 I'm trying to cache the output of an ApiController method in Web API. Here's the controller code: public class TestController : ApiController { [OutputCache(Duration = 10, VaryByParam = "none", Location = OutputCacheLocation.Any)] public string Get() { return System.DateTime.Now.ToString(); } } N.B. I'd also tried the OutputCache attribute on the controller itself, as well as several combinations of its parameters. The route is registered in Global.asax: namespace WebApiTest { public class

How to use caching in ASP.NET Web API?

佐手、 提交于 2019-11-26 15:44:56
问题 I am using ASP.NET MVC 4 with WEB API I have the following action, in the action shown below, my service method makes a db call to DoMagic() method and returns an integer value which I am then using on every page, this action is called using an ajax call. Below is my WEB API action : [OutputCache(Duration = 86400, VaryByParam = "none")] [ActionName("GetMyMagicNumber")] public int GetMyMagicNumber() { if (WebSecurity.IsAuthenticated) { var revenue = _magicService.DoMagic(); return revenue; }

Prevent IE11 caching GET call in Angular 2

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 09:38:34
问题 I have a rest endpoint that returns a list on a GET call. I also have a POST endpoint to add new items and a DELETE to remove them. This works in Firefox and Chrome, and the POST and DELETE work in IE11. However, the GET in IE11 only works on initial load of the page. Refreshing returns cached data. I have seen post about this behavior in Angular 1 but nothing for Angular 2(release candidate 1). 回答1: Today, I also had this problem, (damn IE). In my project, I use httpclient , that hasn't

Is it possible to cache POST methods in HTTP?

血红的双手。 提交于 2019-11-25 18:57:27
With very simple caching semantics: if the parameters are the same (and the URL is the same, of course), then it's a hit. Is that possible? Recommended? The corresponding RFC 2616 in section 9.5 (POST) allows the caching of the response to a POST message, if you use the appropriate headers. Responses to this method are not cacheable, unless the response includes appropriate Cache-Control or Expires header fields. However, the 303 (See Other) response can be used to direct the user agent to retrieve a cacheable resource. Note that the same RFC states explicitly in section 13 (Caching in HTTP)