Sunday, June 8, 2014

HTTP The Definitive Guide (Publishing Systems)

Publishing Systems
FrontPage Server Extensions for Publishing Support
FrontPage Server Extensions
Our primary interest lies in the publishing protocol between the FP clients and FPSE. This protocol provides an example of designing extensions to the core services available in HTTP without changing HTTP semantics.

FrontPage Vocabulary

  • Virtual server - A web server that supports virtual servers is called a multi-hosting web server. A machine that is configured with multiple IP addresses is called a multi-homed server
  • Root web - The default, top-level content directory of a web server, or, in a multi-hosting environment, the top-level content directory of a virtual web server. 
  • Subweb - A named subdirectory of the root web or another subweb that is a complete FPSE extended web.

The FrontPage RPC Protocol
FrontPage Security Model

WebDAV and Collaborative Authoring
Web Distributed Authoring and Versioning (WebDAV) adds an extra dimension to web publishing—collaboration.
WebDAV Methods

  • PROPFIND - Retrieves the properties of a resource.
  • PROPPATCH - Sets one or more properties on one or many resources.
  • MKCOL - Creates collections.
  • COPY - Copies a resource or a collection of resources from a given source to a given destination. The destination need not be on the same machine.
  • MOVE - Moves a resource or a collection of resources from a given source to a given destination. The destination need not be on the same machine.
  • LOCK - Locks a resource or multiple resources.
  • UNLOCK - Unlocks a previously locked resource.
WebDAV and XML

XML provides WebDAV with:
  • A method of formatting instructions describing how data is to be handled
  • A method of formatting complex responses from the server
  • A method of communicating customized information about the collections and resources handled
  • A flexible vehicle for the data itself
  • A robust solution for most of the internationalization issues
WebDAV Headers

  • DAV
  • Depth
  • Destination
  • If
  • Lock-Token
  • Overwrite
  • Timeout
WebDAV Locking and Overwrite Prevention


WebDAV supports two types of locks:
  • Exclusive write locking of a resource or a collection - An exclusive write lock guarantees write privileges only to the lock owner. This type of locking completely eliminates potential conflicts.
  • Shared write locking of a resource or a collection - A shared write lock allows a group of people to work on a given document. This type of locking works well in an environment where all the authors are aware of each other’s activities.
The LOCK Method

The UNLOCK Method

Properties and META Data
The PROPFIND Method
The PROPPATCH Method
Collections and Namespace Management
The MKCOL Method
The DELETE Method
The COPY and MOVE Methods
Overwrite header effect
COPY/MOVE of properties
Locked resources and COPY/MOVE


Enhanced HTTP/1.1 Methods
The PUT method
The OPTIONS method
Using the OPTIONS method, the client tries to establish the capability of the WebDAV server.

Version Management in WebDAV

Future of WebDAV






































HTTP The Definitive Guide (Web Hosting)

Web Hosting
Hosting Services
A Simple Example: Dedicated Hosting
Virtual Hosting
Virtual Server Request Lacks Host Information
Making Virtual Hosting Work


Virtual hosting by URL path
In general, URL-based virtual hosting is a poor solution and seldom is used.

Virtual hosting by port number
Virtual hosting by IP address
A much better approach (in common use) is virtual IP addressing. Here, each virtual web site gets one or more unique IP addresses. The IP addresses for all of the virtual web sites are attached to the same shared server. The server can look up the destination IP address of the HTTP connection and use that to determine what web site the client thinks it is connected to.
Virtual IP hosting works, but it causes some difficulties, especially for large hosters:

  • Computer systems usually have a limit on how many virtual IP addresses can be bound to a machine. Hosters that want hundreds or thousands of virtual sites to be hosted on a shared server may be out of luck.
  • IP addresses are a scarce commodity. Hosters with many virtual sites might not be able to obtain enough virtual IP addresses for the hosted web sites.
  • The IP address shortage is made worse when hosters replicate their servers for additional capacity. Different virtual IP addresses may be needed on each replicated server, depending on the load-balancing architecture, so the number of IP addresses needed can multiply by the number of replicated servers.


Virtual hosting by Host header


HTTP/1.1 Host Headers
Syntax and usage
Interpreting Host headers
Host headers and proxies

Making Web Sites Reliable
There are several times during which web sites commonly break:

  • Server downtime
  • Traffic spikes: suddenly everyone wants to see a particular news broadcast or rush to a sale. Sudden spikes can overload a web server, slowing it down or stopping it completely.
  • Network outages or losses

Mirrored Server Farms
A server farm is a bank of identically configured web servers that can cover for each other. The content on each server in the farm can be mirrored, so that if one has a problem, another can fill in.



In the Figure 18-7 scenario, there are a couple of ways that client requests would be directed to a particular server:
  • HTTP redirection - The URL for the content could resolve to the IP address of the master server, which could then send redirects to replica servers.
  • DNS redirection - The URL for the content could resolve to four IP addresses, and the DNS server could choose the IP address that it sends to clients.
Content Distribution Networks
A content distribution network (CDN) is simply a network whose purpose is the distribution of specific content. The nodes of the network can be web servers, surrogates, or proxy caches.

Surrogate Caches in CDNs
Proxy Caches in CDNs

Making Web Sites Fast







































































HTTP The Definitive Guide (Content Negotiation and Transcoding)

Content Negotiation and Transcoding
Content-Negotiation Techniques
There are three distinct methods for deciding which page at a server is the right one for a client: present the choice to the client, decide automatically at the server, or ask an intermediary to select.

Client-Driven Negotiation
The easiest thing for a server to do when it receives a client request is to send back a response listing the available pages and let the client decide which one it wants to see.

Server-Driven Negotiation
There are two mechanisms that HTTP servers use to evaluate the proper response to send to a client:

  • Examining the set of content-negotiation headers. The server looks at the client’s Accept headers and tries to match them with corresponding response headers.
  • Varying on other (non–content-negotiation) headers. For example, the server could send responses based on the client’s User-Agent header.
Server-Driven Negotiation


Content-Negotiation Headers

Content-Negotiation Header Quality Values

Varying on Other Headers
Servers also can attempt to match up responses with other client request headers, such as User-Agent.
the Vary header tells caches (and clients, and any downstream proxies) which headers the server is using to determine the best version of the response to send.

Content Negotiation on Apache
There are two ways to enable content negotiation:

  • In the web site directory, create a type-map file for each URI in the web site that has variants. The type-map file lists all the variants and the content-negotiation headers to which they correspond.
  • Enable the MultiViews directive, which causes Apache to create type-map files for the directory automatically.

Using type-map files
Using MultiViews

Server-Side Extensions

Transparent Negotiation
Transparent negotiation seeks to move the load of server-driven negotiation away from the server, while minimizing message exchanges with the client by having an intermediary proxy negotiate on behalf of the client.
Servers send Vary headers in their responses to tell intermediaries what request headers they use for content
negotiation.

Caching and Alternates
The Vary Header

If a server’s Vary header looked like this, the huge number of different User-Agent and Cookie values could generate many variants:
Vary: User-Agent, Cookie
A cache would have to store each document version corresponding to each variant. When the cache does a lookup, it first does content matching with the content-negotiation headers, then matches the request’s variant with cached variants. If there is no match, the cache fetches the document from the origin server.

Transcoding

There are three categories of transcoding: format conversion, information synthesis, and content injection.


Format Conversion
Information Synthesis
Content Injection
Examples of contentinjection transcodings are automatic ad generators and user-tracking systems.

Transcoding Versus Static Pregeneration
Next Steps
















































Wednesday, May 28, 2014

HTTP The Definitive Guide (Internationalization)

Internationalization
This chapter covers two primary internationalization issues for the Web: character set encodings and language tags.
HTTP applications use character set encodings to request and display text in different alphabets, and they use language tags to describe and restrict content to languages the user understands.

HTTP Support for International Content
Servers tell clients about a document’s alphabet and language with the HTTP Content-Type charset parameter and Content-Language headers. These headers describe what’s in the entity body’s “box of bits,” how to convert the contents into the proper characters that can be displayed onscreen, and what spoken language the words represent.

At the same time, the client needs to tell the server which languages the user understands and which alphabetic coding algorithms the browser has installed. The client sends Accept-Charset and Accept-Language headers to tell the server which character set encoding algorithms and languages the client understands, and which of them are preferred.

Accept-Language: fr, en;q=0.8
Accept-Charset: iso-8859-1, utf-8

Character Sets and HTTP
Charset Is a Character-to-Bits Encoding

How Character Sets and Encodings Work
Bits-to-character conversions happen in two steps,

  • In Figure 16-2a, bits from a document are converted into a character code that identifies a particular numbered character in a particular coded character set. In the example, the decoded character code is numbered 225.
  • In Figure 16-2b, the character code is used to select a particular element of the coded character set. In iso-8859-6, the value 225 corresponds to “ARABIC LETTER FEH.” The algorithms used in Steps a and b are determined from the MIME charset tag.
The Wrong Charset Gives the Wrong Characters
Standardized MIME Charset Values
Content-Type Charset Header and META Tags
Web servers send the client the MIME charset tag in the Content-Type header, using
the charset parameter:
Content-Type: text/html; charset=iso-2022-jp

For HTML content, character sets might be found in <META HTTP-EQUIV="Content-Type"> tags that describe the charset.
If a client cannot infer a character encoding, it assumes iso-8859-1.

The Accept-Charset Header
HTTP clients can tell servers precisely which character systems they support, using the Accept-Charset request header.

Multilingual Character Encoding Primer
Character Set Terminology

  • Character
  • Glyph - A character may have multiple glyphs if it can be written different ways
  • Coded character
  • Coding space - A range of integers that we plan to use as character code values.
  • Code width - The number of bits in each (fixed-size) character code.
  • Character repertoire - A particular working set of characters (a subset of all the characters in the world).
  • Coded character set
  • Character encoding scheme - An algorithm to encode numeric character codes into a sequence of content bits (and to decode them back).
Charset Is Poorly Named
Technically, the MIME charset tag (used in the Content-Type charset parameter and the Accept-Charset header) doesn’t specify a character set at all. The MIME charset value names a total algorithm for mapping data bits to codes to unique characters. It combines the two separate concepts of character encoding scheme and coded character set.

Characters

Glyphs, Ligatures, and Presentation Forms
Here’s the general rule: if the meaning of the text changes when you replace one glyph with another, the glyphs are different characters. Otherwise, they are the same characters, with a different stylistic presentation.

Coded Character Sets
US-ASCII: The mother of all character sets
“American Standard Code for Information Interchange.”
HTTP messages (headers, URIs, etc.) use US-ASCII.

iso-8859
The iso-8859 character set standards are 8-bit supersets of US-ASCII that use the high bit to add characters for international writing.

iso-8859-1, also known as Latin1, is the default character set for HTML.

JIS X 0201
JIS X 0201 is an extremely minimal character set that extends ASCII with Japanese half width katakana characters. JIS is an acronym for “Japanese Industrial Standard.”

JIS X 0208 and JIS X 0212
The JIS X 0208 character set was the first multi-byte Japanese character set; it defined 6,879 coded characters, most of which are Chinese-based kanji. The JIS X 0212 character set adds an additional 6,067 characters.

UCS
The Universal Character Set (UCS) is a worldwide standards effort to combine all of the world’s characters into a single coded character set.

Character Encoding Schemes

  • Fixed width
  • Variable width (nonmodal) -Variable-width encodings use different numbers of bits for different character code numbers.
  • Variable width (modal) - Modal encodings use special “escape” patterns to shift between different modes. For example, a modal encoding can be used to switch between multiple, overlapping character sets in the middle of text.
Encoding schemes:
8-bit - It supports only character sets with a code range of 256 characters. The iso-8859 family of character sets uses the 8-bit identity encoding.

UTF-8 - UTF stands for “UCS Transformation Format”  UTF-8 uses a nonmodal, variable-length encoding for the character code values, where the leading bits of the first byte tell the length of the encoded character in bytes, and any subsequent byte contains six bits of code value. For example, character code 90 (ASCII “Z”) would be encoded as 1 byte (01011010), while code 5073 (13-bit binary value 1001111010001) would be encoded into 3 bytes:
11100001 10001111 10010001
iso-2022-jp
iso-2022-jp is a variable-length, modal encoding, with all values less than 128 to prevent problems with non–8-bit-clean software.
The encoding context always is set to one of four predefined character sets.* Special “escape sequences” shift from one set to another.

euc-jp
EUC stands for “Extended Unix Code,” first developed to support Asian characters on Unix operating systems.
Like iso-2022-jp, the euc-jp encoding is a variable-length encoding that allows the use of several standard Japanese character sets. But unlike iso-2022-jp, the euc-jp encoding is not modal. There are no escape sequences to shift between modes.


Language Tags and HTTP
The Content-Language Header
The Accept-Language Header
Clients use Accept-Language and Accept-Charset to request content they can understand.

Types of Language Tags
Language tags can be used to represent:

  • General language classes (as in “es” for Spanish)
  • Country-specific languages (as in “en-GB” for English in Great Britain)
  • Dialects of languages (as in “no-bok” for Norwegian “Book Language”)
  • Regional languages (as in “sgn-US-MA” for Martha’s Vineyard sign language)
  • Standardized nonvariant languages (e.g., “i-navajo”)
  • Nonstandard languages (e.g., “x-snowboarder-slang”*)

Subtags
Language tags have one or more parts, separated by hyphens, called subtags:

  • The first subtag called the primary subtag. The values are standardized.
  • The second subtag is optional and follows its own naming standard.
  • Any trailing subtags are unregistered.

Capitalization
However, lowercasing conventionally is used to represent general languages, while uppercasing is
used to signify particular countries.

IANA Language Tag Registrations

First Subtag: Namespace
If the first subtag has:

  • Two characters, it is a language code from the ISO 639† and 639-1 standards 
  • Three characters, it is a language code listed in the ISO 639-2‡ standard and extensions
  • The letter “i,” the language tag is explicitly IANA-registered
  • The letter “x,” the language tag is a private, nonstandard, extension subtag

Second Subtag: Namespace
If the second subtag has:

  • Two characters, it’s a country/region defined by ISO 3166*
  • Three to eight characters, it may be registered with the IANA
  • One character, it is illegal

Remaining Subtags: Namespace
There are no rules for the third and following subtags, apart from being up to eight characters (letters and digits).

Configuring Language Preferences


Internationalized URIs
Global Transcribability Versus Meaningful Characters

URI Character Repertoire

Escaping International Characters
Note that escape values should be in the range of US-ASCII codes (0–127).

Modal Switches in URIs

Other Considerations
Headers and Out-of-Spec Data
HTTP headers must consist of characters from the US-ASCII character set.

Dates
Domain Names



























































HTTP The Definitive Guide (Entities and Encodings)

Entities and EncodingsIn particular, HTTP ensures that its cargo:
  • Can be identified correctly (using Content-Type media formats and Content-Language headers) so browsers and other clients can process the content properly
  • Can be unpacked properly (using Content-Length and Content-Encoding headers) 
  • Is fresh (using entity validators and cache-expiration controls)
  • Meets the user’s needs (based on content-negotiation Accept headers)
  • Moves quickly and efficiently through the network (using range requests, delta encoding, and other data compression)
  • Arrives complete and untampered with (using transfer encoding headers and
  • Content-MD5 checksums)
Messages Are Crates, Entities Are Cargo
HTTP/1.1 defines 10 primary entity header fields:
Content-Type
        The kind of object carried by the entity.
Content-Length
        The length or size of the message being sent.
Content-Location
        An alternate location for the object at the time of the request.
Content-Range
        If this is a partial entity, this header defines which pieces of the whole are included.
Content-MD5
        A checksum of the contents of the entity body.
Last-Modified
        The date on which this particular content was created or modified at the server.
Expires
        The date and time at which this entity data will become stale.
Allow
        What request methods are legal on this resource; e.g., GET and HEAD.
ETag
        A unique validator for this particular instance* of the document. The ETag header is not defined                     formally as an entity header, but it is an important header for many operations involving entities.
Cache-Control
        Directives on how this document can be cached. The Cache-Control header, like the ETag header, is         not defined formally as an entity header.

Entity Bodies

  • In Figure 15-2a, the entity body begins at byte number 65, right after the end-ofheaders CRLF. The entity body contains the ASCII characters for “Hi! I’m a message!”
  • In Figure 15-2b, the entity body begins at byte number 67. The entity body contains the binary contents of the GIF image. GIF files begin with 6-byte version signature, a 16-bit width, and a 16-bit height. You can see all three of these directly in the entity body.
Content-Length: The Entity’s Size
The Content-Length header is mandatory for messages with entity bodies, unless the message is transported using chunked encoding.

Detecting Truncation
Older versions of HTTP used connection close to delimit the end of a message. But, without Content-Length, clients cannot distinguish between successful connection close at the end of a message and connection close due to a server crash in the middle of a message. Clients need Content-Length to detect message truncation.

Message truncation is especially severe for caching proxy servers. Caching proxy servers generally do not cache HTTP bodies that don’t have an explicit Content-Length header, to reduce the risk of caching truncated messages.

Incorrect Content-Length
An incorrect Content-Length can cause even more damage than a missing Content-Length.

Content-Length and Persistent Connections
Content-Length is essential for persistent connections.If the response comes across a persistent connection, another HTTP response can immediately follow the current response. The Content-Length header lets the client know where one message ends and the next begins. Because the connection is persistent, the client cannot use connection close to identify the message’s end. Without a Content-Length header, HTTP applications won’t know where one entity body ends and the next message begins.
As we will see in “Transfer Encoding and Chunked Encoding,” there is one situation where you can use persistent connections without having a Content-Length header: when you use chunked encoding.

Content Encoding
If the body has been content-encoded, the Content-Length header specifies the length, in bytes, of the encoded body, not the length of the original, unencoded body.

Rules for Determining Entity Body Length
The rules should be applied in order; the first match applies.

  • If a particular HTTP message type is not allowed to have a body, ignore the Content-Length header for body calculations.
  • If a message contains a Transfer-Encoding header (other than the default HTTP “identity” encoding), the entity will be terminated by a special pattern called a “zero-byte chunk,” unless the message is terminated first by closing the connection.
  • If a message has a Content-Length header (and the message type allows entity bodies), the Content-Length value contains the body length, unless there is a non-identity Transfer-Encoding header. If a message is received with both a Content-Length header field and a non-identity Transfer-Encoding header field, you must ignore the Content-Length, because the transfer encoding will change the way entity bodies are represented and transferred (and probably the number of bytes transmitted)
  • If the message uses the “multipart/byteranges” media type and the entity length is not otherwise specified (in the Content-Length header), each part of the multipart message will specify its own size. This multipart type is the only entity body type that self-delimits its own size, so this media type must not be sent unless the sender knows the recipient can parse it.
  • If none of the above rules match, the entity ends when the connection closes.
  • To be compatible with HTTP/1.0 applications, any HTTP/1.1 request that has an entity body also must include a valid Content-Length header field (unless the server is known to be HTTP/1.1-compliant).
Entity Digests
The Content-MD5 header is used by servers to send the result of running the MD5 algorithm on the entity body. The Content-MD5 header contains the MD5 of the content after all content encodings have been applied to the entity body and before any transfer encodings have been applied to it.

Media Type and Charset
The Content-Type header field describes the MIME type of the entity body.
If the entity has gone through content encoding, for example, the Content-Type header will still specify the entity body type before the encoding.

Character Encodings for Text Media
        Content-Type: text/html; charset=iso-8859-4

Multipart Media Types
MIME “multipart” email messages contain multiple messages stuck together and sent as a single, complex message. Each component is self-contained, with its own set of headers describing its content; the different components are concatenated together and delimited by a string. HTTP also supports multipart bodies; however, they typically are sent in only one of two situations: in fill-in form submissions and in range responses carrying pieces of a document.

Multipart Form Submissions
When an HTTP fill-in form is submitted, variable-length text fields and uploaded objects are sent as separate parts of a multipart body, allowing forms to be filled out with values of different types and lengths.
Example:

1.
Content-Type: multipart/form-data; boundary=AaB03x
--AaB03x
Content-Disposition: form-data; name="submit-name"
Sally
--AaB03x
Content-Disposition: form-data; name="files"; filename="essayfile.txt"
Content-Type: text/plain
...contents of essayfile.txt...
--AaB03x--

2.
Content-Type: multipart/form-data; boundary=AaB03x
--AaB03x
Content-Disposition: form-data; name="submit-name"
Sally
--AaB03x
Content-Disposition: form-data; name="files"
Content-Type: multipart/mixed; boundary=BbC04y
--BbC04y
Content-Disposition: file; filename="essayfile.txt"
Content-Type: text/plain
...contents of essayfile.txt...
--BbC04y
Content-Disposition: file; filename="imagefile.gif"
Content-Type: image/gif
Content-Transfer-Encoding: binary
...contents of imagefile.gif...
--BbC04y--
--AaB03x--

Multipart Range Responses
HTTP responses to range requests also can be multipart. Such responses come with a Content-Type: multipart/byteranges header and a multipart body with the different ranges.

Example:

HTTP/1.0 206 Partial content
Server: Microsoft-IIS/5.0
Date: Sun, 10 Dec 2000 19:11:20 GMT
Content-Location: http://www.joes-hardware.com/gettysburg.txt
Content-Type: multipart/x-byteranges; boundary=--[abcdefghijklmnopqrstuvwxyz]--
Last-Modified: Sat, 09 Dec 2000 00:38:47 GMT
--[abcdefghijklmnopqrstuvwxyz]--
Content-Type: text/plain
Content-Range: bytes 0-174/1441
Fourscore and seven years ago our fathers brough forth on this continent
a new nation, conceived in liberty and dedicated to the proposition that
all men are created equal.
--[abcdefghijklmnopqrstuvwxyz]--
Content-Type: text/plain
Content-Range: bytes 552-761/1441
But in a larger sense, we can not dedicate, we can not consecrate,
we can not hallow this ground. The brave men, living and dead who
struggled here have consecrated it far above our poor power to add
or detract.
--[abcdefghijklmnopqrstuvwxyz]--
Content-Type: text/plain
Content-Range: bytes 1344-1441/1441
and that government of the people, by the people, for the people shall
not perish from the earth.
--[abcdefghijklmnopqrstuvwxyz]--

Content Encoding
The Content-Encoding Process
The content-encoding process is:

  • A web server generates an original response message, with original Content-Type and Content-Length headers.
  • A content-encoding server (perhaps the origin server or a downstream proxy) creates an encoded message. The encoded message has the same Content-Type but (if, for example, the body is compressed) a different Content-Length. The content-encoding server adds a Content-Encoding header to the encoded message, so that a receiving application can decode it.
  • A receiving program gets the encoded message, decodes it, and obtains the original.

Content-Encoding Types
Accept-Encoding Headers
The Accept-Encoding field contains a comma-separated list of supported encodings.
Here are a few examples:
        Accept-Encoding: compress, gzip
        Accept-Encoding:
        Accept-Encoding: *
        Accept-Encoding: compress;q=0.5, gzip;q=1.0
        Accept-Encoding: gzip;q=1.0, identity; q=0.5, *;q=0

Transfer Encoding and Chunked Encoding
Transfer encodings also are reversible transformations performed on the entity body, but they are applied for architectural reasons and are independent of the format of the content. You apply a transfer encoding to a message to change the way message data is transferred across the network.
Safe Transport
In HTTP, there are only a few reasons why transporting message bodies can cause trouble. Two of these are:
Unknown size
Security

Transfer-Encoding Headers
Transfer-Encoding
TE
All transfer-encoding values are case-insensitive. HTTP/1.1 uses transfer-encoding values in the TE header field and in the Transfer-Encoding header field. The latest HTTP specification defines only one transfer encoding, chunked encoding.

Chunked Encoding
Chunked encoding breaks messages into chunks of known size. Each chunk is sent one after another, eliminating the need for the size of the full message to be known before it is sent.

Chunking and persistent connections
Chunked encoding provides a solution for this dilemma, by allowing servers to send the body in chunks, specifying only the size of each chunk. As the body is dynamically generated, a server can buffer up a portion of it, send its size and the chunk, and then repeat the process until the full body has been sent. The server can signal the end of the body with a chunk of size 0 and still keep the connection open and ready for the next response.

Trailers in chunked messages
Any of the HTTP headers can be sent as trailers, except for the Transfer-Encoding, Trailer, and Content-Length headers.

Combining Content and Transfer Encodings
Transfer-Encoding Rules

  • The set of transfer encodings must include “chunked.” The only exception is if the message is terminated by closing the connection.
  • When the chunked transfer encoding is used, it is required to be the last transfer encoding applied to the message body.
  • The chunked transfer encoding must not be applied to a message body more than once.
Time-Varying Instances
The HTTP protocol specifies operations for a class of requests and responses, called instance manipulations, that operate on instances of an object. The two main instance-manipulation methods are range requests and delta encoding.
Validators and Freshness

Freshness
Servers can provide this information using one of two headers: Expires and Cache-Control.
Expires: Sun Mar 18 23:59:59 GMT 2001

The Cache-Control header actually is very powerful. It can be used by both servers and clients to describe freshness using more directives than just specifying an age or expiration time.
Conditionals and Validators
        GET /announce.html HTTP/1.0
        If-Modified-Since: Sat, 29 Jun 2002, 14:30:00 GMT
The If-Modified-Since conditional header tests the last-modified date of a document instance, so we say that the last-modified date is the validator. The If-None-Match conditional header tests the ETag value of a document, which is a special keyword or version-identifying tag associated with the entity. Last-Modified and ETag are the two primary validators used by HTTP.

HTTP groups validators into two classes: weak validators and strong validators.
The last-modified time is considered a weak validator because, although it specifies the time at which the resource was last modified, it specifies that time to an accuracy of at most one second.
The ETag header is considered a strong validator, because the server can place a distinct value in the ETag header every time a value changes.
The server might advertise a “weak” entity tag by prefixing the tag with “W/”.

Range Requests
HTTP goes further: it allows clients to actually request just part or a range of a document.
Example:

GET /bigfile.html HTTP/1.1
Host: www.joes-hardware.com
Range: bytes=4000-
User-Agent: Mozilla/4.61 [en] (WinNT; I)
In the case where clients request multiple ranges in a single request, responses come back as a single entity, with a multipart body and a Content-Type: multipart/byteranges header.

Servers can advertise to clients that they accept ranges by including the header Accept-Ranges in their responses.

HTTP/1.1 200 OK
Date: Fri, 05 Nov 1999 22:35:15 GMT
Server: Apache/1.2.4
Accept-Ranges: bytes
That is, a client’s range request makes sense only if the client and server have the same version of a document.
Delta Encoding
Delta encoding is an extension to the HTTP protocol that optimizes transfers by communicating changes instead of entire objects. Delta encoding is a type of instance manipulation, because it relies on clients and servers exchanging information about particular instances of an object.

A-IM is short for Accept-Instance-Manipulation

Instance Manipulations, Delta Generators, and Delta Appliers


The Unix diff -e algorithm does a line-by-line comparison of files. This obviously is okay for text files but breaks down for binary files. The vcdiff algorithm is more powerful, working even for non-text files and generally producing smaller deltas than diff -e.

A server supporting delta encoding must keep all the different copies of that page as it changes over time, in order to figure out what’s changed between any requesting client’s copy and the latest copy.