13
Chapter 3 Web Proxy Caching
HTTP object freshness tests
Here is how Traffic Server determines an HTTP document’s freshness:
Expires header test. Some documents come with Expires headers or max-age headers that e xplicitly
define how long the document may be c ached. A simple comparison of the current time with the e xpiration
time tells T raffic Server whether or not the document is fresh.
Last-Modified / Date header test. If there is no expiration information, a freshness limit can be estimated
from the
Last-Modified and Date headers. The Last-Modified header indicates how long ago a
document was modified. If a document was last modified two years ago, it is unlikely to suddenlychange, so
Traffic Server can cache it safely for a while.B ut ifthedocument just changed 5 minutes ago, it’s likely to be
volatile,and Traffic Server should not cache it forlong.TrafficServer uses a formula to determine the length
of time it considers a stored object to be fresh. Traffic Server stores an object for s ome percentage (F) of the
time that elapsed since it last changed, 10% by default:
freshnesslimit=F*(Date-Last-Modified)
Where the Date header provides the date the object was sent to Traffic Server, and the Last-Modified
header provides the date the object was last modified on the origin server.
For example, if a document was last m odified 32 days ago and was sent to Traffic Server 2 days ago, it is
considered fresh in cachefor 3 days after it was sent, assuming a factor of 10%. It is considered fresh for one
more day.
Because this method might select large freshness times for documents that have not changed for a long time,
cache administratorsmaywant to place an upper boundary on the freshness limit. The freshness limit, then, is
the minimum of this upper boundary and the computed freshness limit.You configure this upper boundary in
the Freshness sectionof the Configure:Cachepageof TrafficManager. (Minimum freshness information
for a document to be cacheable is one of the configuration options under Freshness.)
Default test. For documents that do not have Expires headers or do not have both Last-Modified and
Date headers, you can specifyan absolute freshness limit in t he Freshness section of the Configure: Cache
page.
Revalidate rules in the cache.config file. Revalidate rules apply specific freshness limits to specific HTTP
or FTP objects. You can set freshness limits for objects originating from particular domains or IP addresses,
objects with URLs that contain specified regular expressions, objects requested by particular clients, and so
on. See cache.config‚ on page 162.
Deciding whether to serve HTTP objects
Even though a document may be fresh i n the cache, clients or servers may have their own constraints that
prevent them from retrieving the document from the cache. For example, a client might request that a
document not c ome from a cache, or if it does, it cannot have been cached for more than 10 minutes.
Traffic Server bases the servability of a cached document on
Cache-Control header fields. Cache-
Control
headers can appear in both client requests and server responses.
The following cache-control header fields affect whether objects are served:
• The
no-cache field, sentbyclients,tellsTrafficServerto servenoobjects directly from the cache; always
revalidate. You can configure Traffic Server to ignore client
no-cache fields.
• The
max-age field, sent by servers, is compared to the document age; ifthe age is less than the max-age,
the document is fresh and can be served.
• The
min-fresh field, sent by c lients, is an acceptable freshness tolerance.The client wants the object to
be at least this fresh. If a cached document does not remain fresh at least this long in the future, it is
revalidated.
• The
max-stale field, sent by clients, permits Traffic Server to serve stale documents provided they are
not too old. Some browsers may be willing to take slightly old documents in exchange for improved
performance, especially during periods of poor Internet availability.