Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the browser know a web page has changed?

This is a dangerously easy thing I feel I should know more about - but I don't, and can't find much around.

The question is: How exactly does a browser know a web page has changed?

Intuitively I would say that F5 refreshes the cache for a given page, and that cache is used for history navigation only and has an expiration date - which leads me to think the browser never knows if a web page has changed, and it just reloads the page if the cache is gone --- but I am sure this is not always the case.

Any pointers appreciated!

like image 608
JohnIdol Avatar asked Dec 07 '09 20:12

JohnIdol


2 Answers

Don't guess; read the docs. Here's a friendly, but authoritative introduction to the subject.

like image 83
Jonathan Feinberg Avatar answered Oct 02 '22 14:10

Jonathan Feinberg


Browsers will usually get this information through HTTP headers sent with the page.

For example, the Last-Modified header tells the browser how old the page is. A browser can send a simple HEAD request to the page to get the last-modified value. If it's newer than what the browser has in cache, then the browser can reload it.

There are a bunch of other headers related to caching as well (like Cache-Control). Check out: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

like image 37
Seth Avatar answered Oct 02 '22 14:10

Seth