The Conditional GET

The Conditional GET

Though caching can decrease user-perceived response times, it initiates a new problem - the copy of an object residing in the cache may be stale. In other words, the object housed in the Web server may have been modified since the copy was cached at the client. Fortunately, HTTP  has a system that allows a cache to confirm that its objects are up to date. This system is called the conditional GET. An HTTP request message is a so-called conditional GET message if (1) the request message uses the GET method and (2) the request messnge contains an If-Modified-Since: header line.

To demonstrate how the conditional GET operates. let's walk through an instance. First. on the behalf of a requesting browser, a proxy cache send a request message to a Web server:

GET  /fruit/kiwi.gif  HTTP/1.1

Second, the Web server sends a response message with the requested object to the cache:

HTTP/1.1 200 OK
Date: Sat, 7 Jul 2007 15:39:29
Server: Apache/1.3.0 (Unix)
Last-Modified: Wed, 4 Jul 2007 09:23:24
Content-Type: image/gif

(data data data data data . . . )

The cache forwards the object to the requesting browser but also caches the object locally. Importantly, the cache also stores the last-modified date along with the object. Third, one week later, another browser requests the same object via the cache, and the object is still in the cache. Since this object may have been modified at the Web server in the past week, the cache performs an up-to-date check by issuing a conditional GET. Particularly, the cache sends:

GET  /fruit/kiwi.gif  HTTP/1.1
If-modified-since: Wed, 4 Jul 2007 09:23:24

Note that the value of the If-modified-since: header line is exactly equal to the value of the Last-Modified: header line that was sent by the server one Week ago. This conditional GET is telling the server to send the object only if the object has been modified since the specified date. Assume the object has not been modified since 4 Jul 2007 09:23:24. Then, fourth, the Web server sends a response message to the cache:

HTTP/1.1 304 Not Modified
Date: Sat , 14 Jul 2007 15:39:29
Server: Apache/l.3.0 (Unix)

(empty entity body)

We see that in response to the conditional GET, the Web server still sends a response message but does not contain the requested object in the response message. Including the requsted object would only waste bandwidth and increase user-perceived response time, particularly if the object is large. Note that this last response message has 304 Not Modified in the status line, which tells the cache that it can go ahead and forward its (the proxy cache's) cached copy of the object to the requesting browser.

This ends our discussion of HTTP, the first Internet protocol (an application-layer protocol) that we've studied in detail. We've seen the format of HTTP messages and the actions taken by the Web client and server as these messages are sent and received. We've also studied a bit of the Web's application infrastructure, including caches, cookies, and back-end databases, all of which are tied in some way to the HTTP protocol.


web server, conditional get, proxy cache, internet protocol, http protocol

Copy Right

The contents available on this website are copyrighted by TechPlus unless otherwise indicated. All rights are reserved by TechPlus, and content may not be reproduced, published, or transferred in any form or by any means, except with the prior written permission of TechPlus.