Practical mod_perl / HTML Book / books


previous page: 16.2.1. Content-Type Headerpage up: HTML Version of the booknext page: 16.2.3. Entity Tags

16.2.2. Content-Length Header


Search







modperlbook.org


 HTML Book


 PDF Book


 Download Code


 Table of Contents


 Errata


 mod_perl2 User's Guide


 Sitemap





Add to Google



Creative Commons License


Written by
Eric Cholet (Logilune)
and Stas Bekman (StasoSphere).

Hosted by ibiblio.org.



According to section 14.13 of the HTTP specification, the Content-Length header is the number of octets (8-bit bytes) in the body of a message. If the length can be determined prior to sending, it can be very useful to include it. The most important reason is that KeepAlive requests (when the same connection is used to fetch more than one object from the web server) work only with responses that contain a Content-Length header. In mod_perl we can write:

$r->header_out('Content-Length', $length);

When using Apache::File, the additional set_content_length( ) method, which is slightly more efficient than the above, becomes available to the Apache class. In this case we can write:

$r->set_content_length($length);

The Content-Length header can have a significant impact on caches by invalidating cache entries, as the following extract from the specification explains:

The response to a HEAD request MAY be cacheable in the sense that the information 
contained in the response MAY be used to update a previously cached entity from that 
resource.  If the new field values indicate that the cached entity differs from the 
current entity (as would be indicated by a change in Content-Length, Content-MD5, 
ETag or Last-Modified), then the cache MUST treat the cache entry as stale.

It is important not to send an erroneous Content-Length header in a response to either a GET or a HEAD request.

 

Continue to:

  • prev: 16.2.1. Content-Type Header
  • Table of Contents
  • next: 16.2.3. Entity Tags

Tags

mod_perl, modperl, Apache, perl, cgi, html, mod_perl, e-commerce, scalability, free, open source, OSS, apache, squid, high availability, modperl, linux, unix, Web, www, mod_perl, webserver, admin, apache, book, webmaster, tools, modperl, guide, docs, documentation, help, mod_perl, perl, information, apache, script, errata, eric cholet, perl, apache, mod-perl, stas bekman, mod_perl, cool, perl, Apache, performance, speed, choice




Other projects to check out: meta-religion.com is for those interested in Religious, Spiritual and Esoteric Phenomena. i-want-a-better.com is a community of people discussing what they would like to be improved in their lives and things they use and interact with. You may also want to find a healer in your area or read articles on variety of topics.






TOP
previous page: 16.2.1. Content-Type Headerpage up: HTML Version of the booknext page: 16.2.3. Entity Tags

© 2007 StasoSphere

[ Privacy Policy ] [ Terms of Use ] [ About Authors ] [ Search ]

Last modified Tue Feb 24 12:54:56 2009