soda
soda

Reputation: 523

The .html page not added in service-worker.js is cached and is available offline?

I am building a PWA. For testing purposes I added a test .html page which was not in the sw.js folder and was not to be cached ( at least what i expected). I also added a few test external links. After deploying and installing on a phone. In offline mode the external links don't open. But the test page which was'nt in sw.js is still loaded instantly suggesting it's cached too.

Can someone explain this behavior?

For Info:

The sw.js is present at the root of the directory and it's scope is the entire directory. Also the page that has the link to the test page is cached.

Upvotes: 2

Views: 116

Answers (1)

Anand
Anand

Reputation: 10110

If you have the scope at the root level, it will cache everything internal to it... default service worker helper classes tend to cache all html, css and JS files in scope. Unless you post your SW code, can’t say if something else is happening in your case which is unlikely.

Service workers are specific to your domain and sub domain. So naturally, it wouldn’t cache external likes, which you have experienced it.

In both the scenario, Service Worker seem to have worked the way it is intended to.

Upvotes: 2

Related Questions