2

I have an asp.net mvc application which has the following setting in its web.config file:

<staticContent>
  <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
</staticContent>

My main page is served from the following action of my controller:

[OutputCache(Duration = 10, Location = OutputCacheLocation.Client, VaryByParam = "*")]
public ActionResult Index()
{
       // ...
       return View();
}

As one might guess, this is telling the browser to cache the Index page for 10 seconds. Looking at the headers in Chrome, I see the following: enter image description here

The current time at which this request is made is exactly 15:56:50

My questions are:

  • Given that the Expires header says: 14:46:57, why does Chrome fetch the page from its cache when I navigate out and back (using the back button) instead of going to the server?
  • How can I tell the browser to go fetch the new pages that expired?
GETah
  • 20,922
  • 7
  • 61
  • 103
  • Can you offer any more context? Are you trying to auto-refresh the index page..or? – Mike Wallace Mar 16 '16 at 15:08
  • I am actually navigating out the page and back using the browser back button. Opening the same page in a new browser window has the very same effect, chrome fetches the page from the cache instead of getting a new copy from the server :( – GETah Mar 16 '16 at 15:14
  • Got it. I know you can do this with Javascript regardless of the timeout...also that might solve a potential second issue of whether or not the users will spend 11 or more seconds on the second page. I'll not post the script since it doesn't answer the question (there are multiple examples already on SO if you do end up wanting to go that route) – Mike Wallace Mar 16 '16 at 15:33
  • 1
    Maybe this can help http://stackoverflow.com/questions/16173322/google-chrome-does-not-revalidate-etag-on-back-forth – Captain0 Mar 16 '16 at 15:35
  • When you say "15:56:50", you mean 15:56:50 GMT or 15:56:50 GMT+1? – Luca Ghersi Mar 16 '16 at 16:16
  • I can't understand the problem here. You made a request at 14.56.59 GTM, as Chrome says in Date header. The Expires header says 14.47.07, so the request happened earlier than cache expiration, and after cache generation at 14.46.57. It makes perfect sense based on the headers. – Luca Ghersi Mar 16 '16 at 16:21
  • @LucaGhersi that's GMT+1 so the request is made at **14:56:50** GMT. I am not sure I follow you :) The request is made way after the cache has expired (10 minutes afterwards) and I expected chrome to figure this out and go get a new version of the file from the server – GETah Mar 16 '16 at 16:53
  • @Captain0 That's an excellent pointer. I will dig down that direction and come back to you guys with more info. Thanks a bunch. – GETah Mar 16 '16 at 16:53
  • @Captain0 The link you sent made it! that was exactly what I missed. Thanks a million. I am voting to close my question with a link to the duplicate :) – GETah Mar 16 '16 at 19:58

0 Answers0