Maximum items in a cache
A simpler cache invalidation strategy is limiting the number of items persisted. I call this Maximum Item Invalidation.
This requires service worker logic to check how many items are saved in a specifically named cache. If the cache has saved the maximum number of responses, at least one response is removed before adding a new item.
This strategy requires multiple named caches, which correlate to different types of responses. Each named cache can have a different item limit assigned to manage the different types of responses. You can also assign a difference cache invalidation strategy, which will be discussed shortly.
The ticket application has named caches for events, which are dynamically rendered as they are requested. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access