Definition
Runtime caching
Runtime caching means storing a response in Cache Storage the first time a matching request is actually made by the user, inside the fetch event handler, as opposed to precaching, which loads a known asset list upfront during install. It is the natural fit for content whose full URL set is not known ahead of time, such as user-generated images or paginated API results.
A typical runtime-cached fetch handler matches by URL pattern, e.g. if (event.request.url.includes("/api/products/")) { event.respondWith(networkFirstFor(event.request)); }, applying a specific strategy only to that subset of traffic rather than globally.
Because runtime caches grow unpredictably (every unique product page, every unique avatar), they need an eviction policy — Workbox's workbox-expiration plugin supports both maxEntries and maxAgeSeconds limits per cache to keep storage bounded.
Runtime caching and precaching are complementary in most production configurations: the app shell is precached at install for guaranteed offline boot, while API responses and media are handled with runtime rules tuned per content type.
Google's Workbox routing model (workbox.routing.registerRoute) is the standard way to declare these per-URL runtime rules without hand-writing a large if/else chain inside a single fetch listener.