My output caching doesn't appear to be working as expected This is a controller method to return the default page for my website. I have cached it for 40secs (test -> in live it is cached for much longer)
[OutputCache(Duration = 40, Location = OutputCacheLocation.ServerAndClient, VaryByParam = "none")]
public async Task<ActionResult> Index(){
......
}
I have 2 problems
First
When I hit the endpoint for the first time it is cached correctly on the server and returns the following response header (as expected) among others.
status:200
Cache-Control:"private, max-age=40, s-maxage=0"
When I open a new browser tab and paste in the same endpoint after 5 seconds. it goes to the server and returns a 200 with content and the following header
status:200
Cache-Control:"private, max-age=63622944145, s-maxage=63622944105"
This does not seem correct to me. I expected it to send a request to the server with the an If-modified-since header. If the cached response was rebuilt since the time in the header then it would return a 200 + content else a 304. So in this case as the server cache was not rebuilt it should return a 304. Also as the max-age is so large it is now invalid and thus is immediately regarded as stale. So what am I doing wrong...?
Secondly
I put a breakpoint in my Index method and hit the endpoint from my browser. On the first time I hit the Index endpoint the breakpoint is hit. Subsequent requests to the endpoint do not hit the breakpoint for the next 40 seconds as expected. However if I add a "/" to the end of my endpoint in the browser it will hit the breakpoint ignoring the cache. How do I avoid this ..?