Issue link: https://read.uberflip.com/i/1146286
24 | Chapter 3: Rule 3: Add an Expires Header Expires: Sun, 16 Oct 2016 05:43:02 GMT Cache-Control: max-age=315360000 The actual value for the expiration date varies depending on when the request is received, but in this case, it's always 10 years out. Since Cache-Control takes prece- dence and is expressed in seconds relative to the request, clock synchronization issues are avoided. There is no fixed date to worry about updating, and it works in HTTP/1.0 browsers. The best solution to improve caching across all browsers is to use an Expires header set with ExpiresDefault. A survey of 10 top web sites (see Table 3-1) shows that of the seven that use these headers, five use both Expires and Cache-Control max-age. One uses only Expires and another uses only Cache-Control max-age. Sadly, three don't use either. Empty Cache vs. Primed Cache Using a far future Expires header affects page views only after a user has already vis- ited your site. It has no effect on the number of HTTP requests when a user visits your site for the first time and the browser's cache is empty. Therefore, the impact of this performance improvement depends on how often users hit your pages with a primed cache. It's likely that a majority of your traffic comes from users with a primed cache. Making your components cacheable improves the response time for these users. When I say "empty cache" or "primed cache," I mean the state of the browser's cache relative to your page. The cache is "empty" if none of your page's components are in the cache. The browser's cache might contain components from other web sites, but that doesn't help your page. Conversely, the cache is "primed" if all of your page's cacheable components are in the cache. Table 3-1. Usage of Expires and max-age Web site Expires max-age http://www.amazon.com http://www.aol.com ✓ ✓ http://www.cnn.com http://www.ebay.com ✓ ✓ http://www.google.com ✓ http://www.msn.com ✓ ✓ http://www.myspace.com ✓ http://www.wikipedia.org ✓ ✓ http://www.yahoo.com ✓ ✓ http://www.youtube.com

