Chapter 16. HTTP Headers for Optimal Performance
Header composition is
often
neglected in the CGI world. Dynamic content is dynamic, after all, so
why would anybody care about HTTP headers? Because pages are
generated dynamically, one might expect that pages without a
Last-Modified header are fine, and that an
If-Modified-Since header in the
client’s request can be ignored. This laissez-faire
attitude is a disadvantage when you’re trying to
create a server that is entirely driven by dynamic components and the
number of hits is significant.
If the number of hits on your server is not significant and is never going to be, then it is safe to skip this chapter. But if keeping up with the number of requests is important, learning what cache-friendliness means and how to cooperate with caches to increase the performance of the site can provide significant benefits. If Squid or mod_proxy is used in httpd accelerator mode (as discussed in Chapter 12), it is crucial to learn how best to cooperate with it.
In this chapter, when we refer to a section in the HTTP standard, we
are using HTTP standard 1.1, which is documented in RFC 2616. The
HTTP standard describes many headers. In this chapter, we discuss
only the headers most relevant to caching. We divide them into three
sets: date headers, content headers, and the special
Vary header.
Date-Related Headers
The various headers related to when a document was created, when it was last modified, and when it should be considered stale are discussed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access