Skip to content

API caching

Yash Thakur edited this page Oct 7, 2017 · 6 revisions

Adding Caching to API requests

Wait what? Why do you need to cache API ? With service worker & cache mechanisms, even opaque response can be cached (no kidding!).

You can add caching to api by following method:

api.fetch("api call link", { swcache: 20 });

The swcache will cache the api request with the service worker for mentioned period of seconds.

An example of the same has been mentioned here.