I am working with asp.net mvc 4 output caching and for some reason I cant get it working. What I am looking to do is standard but the output caching never kicks in. I think it may be due to cookies being changed and therefore not caching. I want output cache on the client. All my site is in https and all requests is under https.

Some questions I have:

  1. how can I set up output caching to ignore any changes in cookies?
  2. what should I look for in the response headers to understand if output caching is working or not?
  3. setting the location to ServerAndClient - am i correct in saying this results in caching on the server and in the clients browser?

Thanks.

Further info:

What I have noticed via fiddler is that the http header request contains Cache-Control: max-age=0 but I have no idea how or why its being set to this.

有帮助吗?

解决方案

  1. by default caching attribute ignores the cookies!

  2. you can set breakpoints in your controllers to see if output caching works or not, seems you know where to look! "... contains Cache-Control: max-age=0 but ..."

  3. yes it is correct

and i suggest you to set Duration on the caching filter


look in the web.config file to see if the cacheControlMode attribute is not set to something strange! and if it is s-maxage=0 it is because of shared proxy

set the attribute like this on the controllers that you want to cache

[OutputCache( Duration = 360 )]
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top