Skip to content

Caching

Mark Croxton edited this page Sep 21, 2013 · 30 revisions

What to cache

Global fragments: rendered partials, such as navigational elements, footers, sidebars and other reusable, globally visible page elements (scope="site").

Addressable pages: the unique output of individual pages in your site, where the URI alone is sufficient to generate all possible interaction states ("URI addressibility").

Don't cache

Non-global fragments: Partials that generate output that is specific to the URI or user.

Non-addressable pages: where the URI of a page alone is not sufficent to determine it's interaction state. E.g. forms that POST data, shopping carts, 404 pages.

Cache planning

Build for URI addressability: as far as possible plan you site so that all interaction states are represented by a unique URI.

Stay DRY: separate out commonly used global page fragments into snippets, Low Variables or Stash embeds. Cache structured data, not marked-up data, so you can re-use the data with different markups.

Group like items: use context and/or bundles to create groups of related cached items, so that they can be targetted for cache-breaking.

Use layers: use fragment-caching inside page-caching to allow for progressive cache rebuilds and avoid 'stampedes'.

Clone this wiki locally