Re: Recognizing CGI script responses

Henrik Frystyk Nielsen (frystyk@w3.org)
Mon, 5 Jun 1995 19:09:00 +0500


> The convention is that CGI script generated responses will never have
> Last-modified headers in them.
>
> Http servers attach Last-modified headers when sending normal document
> contents, because they can easily get the last modified date by
> looking at the file date. Servers cannot (automatically) generate a
> Last-modified to go with script output, so they don't. Summarizing,
> CGI scripts are not required by the spec to omit a last-modified
> header, but in practice they all do.
>
> Thus, the lack of Last-modified is a means of telling that a response
> came from a script.

This doesn't necessarily make it a good thing ;-) You can't and shouldn't
make any assumptions on the origin of documents from missing headers!

> As far as I know, all popular proxy caches never cache responses that
> lack both a Last-modified header and an Expires header. Thus, no
> popular proxy will cache CGI script output, unless of course the CGI
> script author adds one of these headers by hand.

There is no reason to forbid caching of CGI scripts (actually from the
fact that you can't tell). A way of doing this is, if you don't get
a Last-Modified or a Expires header, to assume that the document was
last modified when the document was received. Then upon the next request
the cache can issue a "GET If-Modified-Since" and everything works fine!
If the update rate of the script results on the origin server is greater
than the request rate through the cache then band width is saved!

--

Henrik Frystyk frystyk@W3.org World-Wide Web Consortium, Tel + 1 617 258 8143 MIT/LCS, NE43-356 Fax + 1 617 258 8682 77 Massachusetts Avenue Cambridge MA 02154, USA