Caching Limitations

The service worker caching feature also has some limits, even though many applications work perfectly fine even with them. Let's see how it is possible to overcome some of these limits.


Cache interface

The Cache API allows us to store request/response pairs on a local device. It is typically used in the context of service workers, but it can also be accessed from the window scope. Therefore, Cache API can also be used in a standard web app without a service worker enabled.


Nowadays, almost all browsers support it:
Cache API support (from caniuse.com)
Cache API support (from caniuse.com)

As we have previously seen in the code examples, we must always give a unique name to each cache, and it is our responsibility to manage them during runtime.

This is necessary because the cache interface doesn’t offer an expiration time for the cache objects. Therefore, we must invalidate them if new data comes with a new service worker version, replacing the old version.
Moreover, it is a good practice to delete all unused data on a user’s device.

In the next chapter, you will see that each browser has ...