sergej.p
sergej.p

Reputation: 115

How to cache static objects (jquery.js library)?

I don't understand the technology of caching, how to cache a file in the browser so that people don't have to download it every time. can you give any link about this?

Upvotes: 0

Views: 302

Answers (1)

Serhii Mamedov
Serhii Mamedov

Reputation: 1343

Browsers are caching assets by default. But this approach is not reliable because you cannot control when browser caches something. Sometimes caching works, sometimes it doesn't.

Much more reliable approach is to use service workers. With them you have complete control of what you cache. You can even cache entire pages and provide offline support with this technology.

Here is a pretty good article about service workers from google: https://developers.google.com/web/ilt/pwa/caching-files-with-service-worker

Upvotes: 1

Related Questions