An HTTP Status Code. If a user agent requests a resource for which it already has a local/cached copy, it may wish to determine if the server has an updated version. If so then it does not need to waste time and bandwidth downloading the resource again.

To do this, it may wish to send an if-modified-since header. The data for this header is the last-modified date and time of the local copy of the resource.

If the resource has not been updated since the if-modified-since date, the server can return the 304 Not Modified response code, with no body. Otherwise, it returns normally with 200 OK or similar.

For example, a page has been created on a game server hosting company's web site that shows the status of all the servers the company currently hosts—player count, current map, and so on. The entry for each server has beside it an image of the map being played on. The page updates once a minute.

If the page lists twenty servers, and each image is 20KB in size, then each refresh of the page requires the server to upload 400KB of data.

GET /images/hls-cstrike-de_aztec.png HTTP/1.0

HTTP/1.0 200 OK
Last-Modified: Wed, 15 May 2002 10:58:00 GMT
Content-type: image/png
Content-length: 20384

(20k of image data)

The second time the image is requested, the transaction might look like this:

GET /images/hls-cstrike-de_aztec.png HTTP/1.0
If-modified-since: Wed, 15 May 2002 10:48:00 GMT

HTTP/1.0 304 Not Modified

The server has saved itself from sending 20KB down the line. Assumng 400KB per page, eight Megabytes are saved per minute, if twenty (bored) people are watching the page refresh.

The same kind of thing can be done with the ETag header.

Log in or register to write something here or to contact authors.