Conditional GET Proposal for HTTP Caching

This was originally presented to the www-talk mailing list on 7 Jan 1994.

It has since been added to the HTTP specification.


John Ellson wrote:
 I thought you were addressing a cache coherency problem:
    
     before serving a document a cache server should check if 
     the original document still exists and if it is unchanged.
 
     if it no longer exists the no document should be served
     and the cache copy should be purged.
 
     if it has changed then the cache should be refreshed and the
     new version served.
 
     if the original site cannot be contacted then the document
     should be served with a warning that the validity of the
     document could not be verified.
 
     if the document still exists unchanged then the cache copy can
     be served.
     
 It seems that the Expires mechanism is a little more hand-offish than
 this.  Perhaps Expires provides sufficient coherency control?
I really don't think the Expires header should indicate anything other than a hint to the reader (and possible cache manager) that the document should not be considered "current" after a certain date. As such, it doesn't provide any coherency control, as would be expected by an optional header.

A Proposal

The cache coherency problem outlined (very well) above is a separate issue because it requires a special request to the original server to determine the status of the actual document. Although some people have suggested that the HEAD request is sufficient for this purpose, I find it entirely too inefficient for a caching mechanism (because of the server overhead from connecting twice and finding the file twice).

The solution is to implement a conditional GET request -- one that includes a date to be checked against the last-modified date of the information object. Someone on comp.infosystems.www (I didn't save the message) once suggested a solution along these lines in which the normal GET request was followed by some sort of last modification date header similar to the current Content-type, Authorization, etc. Let's call this an If-Modified-Since header.

Formally, if the server receives the request:

      GET /ICShome.html HTTP/1.0
      If-Modified-Since: Thu, 06 Jan 1994 15:57:41 GMT
Then the server would respond in one of the following ways: In this way, cache managers would just send a GET request with the If-Modified-Since date equal to the date it originally requested the local copy of the object it has in its cache.

Note that implementing this protocol would have no effect whatsoever on existing servers and clients. Old clients (and any without caches) would just continue making requests without If-Modified-Since headers. Old servers (at least the NCSA httpd 1.0 and 1.1 that I have used) will already accept a message of the above format and just ignore the If-Modified-Since header.

How's that for a proposal? Please send comments to me at <fielding@ics.uci.edu> or to the www-talk mailing list.


Here's how the discussion has progressed on www-talk:
Roy Fielding <fielding@ics.uci.edu>
Last modified: 19 Jul 1996