Introduction to the Cache API

Learn how the Cache API helps to store files for offline access.

Caching is an essential part of web applications. Today, most hosting providers provide some caching services from their servers. On the other hand, browsers also cache the resources returned from the network requests made by the web apps based on their priorities.

Why do we need a new API if we already have servers and browsers that provide caching? The following reasons explain why:

  • The caching done by servers is mainly for faster page loads and to prevent the heavy usage of the server’s resources. The server caching can’t be used while offline because even to reach out to the server, we need to be online.
  • The caching done by browsers isn’t predictable because we don’t know which resources will be cached. Another drawback of the browser’s cache is that it only helps until the user refreshes the page.

To make web apps behave like native apps, we need more control over the caching process to add, update, and delete resources when needed. This is where the Cache API is useful.

Get hands-on with 1200+ tech skills courses.