Accepting selected projects for Q2 2024 Check availability →
SERVER 02SYSTEM ONLINELAST SYNC: 03:17:44RSS 2.0 — ONLINE
HALF ASSEDTECHNICAL NOTES_
EST. 1999ISSUE 04.2BEST VIEWED AT 1024 × 768
TECHNICAL NOTES / TECHNICAL NOTES / PERFORMANCE / RECORD e0723c
[PERFORMANCE]NOTE

Far-future Expires headers and file versioning

POSTED: 20.10.2009AUTHOR: ADMIN5 MIN READCOMMENTS: 0

Most of the time taken to display a page is spent fetching images, stylesheets and scripts. A far-future Expires header removes those requests for returning visitors, provided each file’s address changes whenever its content does.

Set the headers by type

Configure mod_expires, or the equivalent on other servers, to send an expiry a year ahead for images, CSS and JavaScript, and leave HTML documents on a short or zero lifetime. Confirm the result with a header inspection tool rather than from the configuration file.

Version the filename

Include a version or build number in the file name or path and update references at release. A query-string version is simpler to implement, but some proxy caches will not store addresses containing a query string, which removes part of the benefit.

Review entity tags on clusters

Apache’s default ETag includes the file inode, so the same file on two load-balanced servers produces different validators and avoidable downloads. Configure ETags from size and modification time only, or remove them where Last-Modified is sufficient.

RELEASE CHECK

After enabling long expiry, every unversioned asset change becomes a support call asking the user to refresh. Do not enable the header until the versioning step is part of the release procedure.