- Browser
- Proxy
- Gateway
TODO Difference between proxy and gateway caches.
- HTML meta tags (Pragma: no-cache) - they’re only honored by a few browser caches, not proxy caches (which almost never read the HTML in the document).
- HTTP headers - much better
TODO Describe details and why they don't work.
- max-age (most important here)
- no-store
- public/private
- others
TODO Move other options to some later topic about disabling caching/SSL/etc. ?
From RFC:
If a response includes both an Expires header and a max-age directive, the max-age directive overrides the Expires header, even if the Expires header is more restrictive. This rule allows an origin server to provide, for a given response, a longer expiration time to an HTTP/1.1 (or later) cache than to an HTTP/1.0 cache.
Or, when both Cache-Control and Expires are present, Cache-Control takes precedence.
By using it, caches avoid having to download the entire representation when they already have a copy locally, but they’re not sure if it’s still fresh.
Almost all caches use Last-Modified times as validators; ETag validation is also becoming prevalent.
Most modern Web servers will generate both ETag and Last-Modified headers to use as validators for static content (i.e., files) automatically; you won’t have to do anything.
From RFC:
The preferred behavior for an HTTP/1.1 origin server is to send both a strong entity tag and a Last-Modified value.
TODO What if expiration and validation headers are set?
tips for generating (current_user, @collection.max(:updated_at))
Issues with asset versioning e.g. mylib-1.0.js etc.
Provides automatic versioning
- caching SSL Cache-Control: public
- cookies
Fragment caching - examples on using cache-keys + manual versioning for HTML/translation changes