Are service workers suitable to cache assets from other pages than the one active?

13 views
Skip to first unread message

Luca Reghellin

unread,
Feb 7, 2022, 2:22:55 AM2/7/22
to service-worker-discuss
HI, I'm considering to learn and use service workers to speed up a website I'm currently developing. It's a full custom wordpress site, theme made from zero by me.

I've got some big js and css assets to manage. In detail:

  • one big 'shared' css, and the a lot of page-specific smaller ones

  • one big 'shared' js, and the a lot of page-specific smaller ones

  • another big 'semi-shared' js, which I use only for some pages (where I built a couple of mini Vue apps)

In particular, I'm interested in caching the last one, the 'semi-shared', in background while and when the user is navigating other pages that don't use it, so that when users evcentually come to the vue mini apps, js are already loaded.

So basically, example, while I'm visiting /home or other pages, service workers should load the assets needed for /vue-app. Are the service workers suitable for this?

Brent Kimmel

unread,
Feb 8, 2022, 8:12:33 PM2/8/22
to Luca Reghellin, service-worker-discuss
Not sure if this email reply will make it there... But yeah, this is pretty much exactly what Service Workers are good for. If you use progressive enhancement you can make it completely transparent to your users, too. Otherwise, there's other things you can do with "Service Worker"-adjacent things like window.caches that get you the same perf benefits with a bit more management.

--
You received this message because you are subscribed to the Google Groups "service-worker-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to service-worker-di...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/service-worker-discuss/57c88236-c45b-4ee4-9093-aa116ab72cf3n%40chromium.org.

Brent Kimmel

unread,
Feb 9, 2022, 8:41:25 AM2/9/22
to Luca Reghellin, service-worker-discuss
Here is an article/blog that might also be helpful: https://jakearchibald.com/2016/streams-ftw/
Reply all
Reply to author
Forward
0 new messages