6

Is it possible to tell when a browser is retrieving a page from a cache?

I've thought that opening a new tab and directly browsing to the URL would make a fresh pull request from the server, but after testing (in which certain page tailorings weren't changing), it seems that this does not happen.

So is it possible to tell when a browser is pulling something from a cache versus pulling it straight from the web server?

Hennes
  • 64,768
  • 7
  • 111
  • 168
Coldblackice
  • 5,786
  • 17
  • 56
  • 85
  • In fact, *typing* a URL (or using favorites) often does *not* ask the server if cached content is still valid. Whereas refreshing a page often [makes a browser ask the server](http://superuser.com/questions/89809/how-to-force-refresh-without-cache-in-google-chrome/278393#278393), just to be sure. – Arjan Jul 01 '13 at 19:48

1 Answers1

8

The way I usually tell is to hit CTRL+SHIFT+K, or otherwise open the web debugging console, and watch the "Net" requests as the page loads. If you pay attention to the status codes, you'll see something like

[15:15:26.059] GET http://www.example.com/index.html [HTTP/1.1 304 Not Modified 312ms]

when the cache is used, instead of the normal

[15:15:26.059] GET http://www.example.com/index.html [HTTP/1.1 200 OK 31ms]

And if you want to be really sure that you're not using the cache, hit CTRL+F5 when refreshing.

oKtosiTe
  • 9,408
  • 9
  • 46
  • 70
Ken Bellows
  • 358
  • 3
  • 12
  • Or it might simply show "from cache" when clicking around rather than using a page refresh. – Arjan Jul 01 '13 at 19:46
  • It doesn't quite work for json responses for some reason(with max-age rather than last modified headers) the only giveaway kind of is the response time there. Unless I am missing something – Joe Yahchouchi Oct 19 '17 at 20:27