The activate event
The activate event is the first of our three service worker events to take place, so it may seem odd that we’re talking about it last, but there's a good reason.
The activate event is when we do cache clean up. We ensure that we get rid of any expired cache objects so that our share of the browser cache doesn’t get too cluttered and become terminated.
To do so, we basically delete any cache object whose name doesn't match the current value of CACHE_NAME.
"But Scott," you say, "what if our service worker doesn’t update properly, and still contains the old CACHE_NAME?" This is a valid point. However, as said, our service worker should automatically update whenever there is a byte-sized difference between it and the previous ...
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