100 likes | 333 Views
CS193H: High Performance Web Sites Lecture 7: Add an Expires Header. Steve Souders Google souders@cs.stanford.edu. Announcements. No more hardcopy handouts – view/annotate online. Expires header. Expiration date determines freshness . Can also use Cache-Control: max-age.
E N D
CS193H:High Performance Web SitesLecture 7: Add an Expires Header Steve Souders Google souders@cs.stanford.edu
Announcements No more hardcopy handouts – view/annotate online
Expires header Expiration date determines freshness. Can also use Cache-Control: max-age GET /v-app/scripts/107652916-dom.common.js HTTP/1.1 Host: www.blogger.com User-Agent: Mozilla/5.0 (…) Gecko/2008070208 Firefox/3.0.1 Accept-Encoding: gzip,deflate HTTP/1.1 200 OK Content-Type: application/x-javascript Last-Modified: Mon, 22 Sep 2008 21:14:35 GMT Content-Length: 2066 Content-Encoding: gzip Expires: Mon, 12 Oct 2009 14:57:34 GMT Cache-Control: max-age=31536000 XmoÛHþ\ÿFÖvã*wØoq...
Expires vs. max-age Expires works in HTTP/1.0, max-age in HTTP/1.1 Expires is an absolute date: 12 Oct 2009 14:57:34 GMT max-age is # of seconds until expiration: 31536000 Expires relies on clock synchronization between client and server for short expirations max-age takes precedence over Expires
Sending Expires (Apache) mod_expires <FilesMatch "\.(gif|jpg|js|css)$"> ExpiresDefault "access plus 1 year" </FilesMatch> sends both Expires and max-age: Expires: Mon, 12 Oct 2009 14:57:34 GMT Cache-Control: max-age=315360000
Expires in the Wild – 2007 March 2007
Expires in the Wild – 2008 October 2008
Revving Filenames really, this is independent of Expires headers once you make a resource public, you can never change it => aggressive proxies prevent 100% of users from getting the update best solution: change the filename date: trough_062308.gif version #: onload_1.6.1.js checksum: 1076572916-dom.common.js don't use querystring: wikibits.js?179 won't be cached by some proxies
Homework "Improving Top Site" class project: first set of improvements due by 23:59 Mon 10/22 THIS WILL AFFECT YOUR GRADE includes improvements from Rules 1-4 measure improvements using Hammerhead record results in your personal Web 100 sheet include URLs that I can check (in your sheet) read Chapter 4 of HPWS for 10/15
Questions What's are some differences between Expires and max-age? What types of resources should an Expires header be used with? Once a resource is cached with a far future expiration date, how can you push updates and ensure users get the new version?