How can you tell when the browser is retrieving from a cache?

5

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?

Coldblackice

Posted 2013-07-01T18:42:39.470

Reputation: 4 774

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, just to be sure.

– Arjan – 2013-07-01T19:48:55.903

Answers

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.

Ken Bellows

Posted 2013-07-01T18:42:39.470

Reputation: 318

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 – 2017-10-19T20:27:45.620

Or it might simply show "from cache" when clicking around rather than using a page refresh. – Arjan – 2013-07-01T19:46:23.207