jekyll-pwa
jekyll-pwa copied to clipboard
Images Not Caching
Great plugin, this is exactly what I need for my use case!
Everything is working as designed, however the Service Worker does not cache images embedded within the posts (it does cache heading images).
Is this by design or am I missing something? Any help would be greatly appreciated?
I think there're two options to cache images with Google Workbox:
- use
precache_glob_patterns
, you can add the filepath of images into the regexp so that they can be precached. But if there're too many images to precache, the installation of service-worker will take a lot of time. So I think only precaching some critical images seems like a better choice. - use
runtime_cache
to cache images embedded within every post in runtime.
I think you can treat different images with different strategies:
precache_glob_patterns:
- "{js,css,fonts}/**/*.{js,css,eot,svg,ttf,woff}"
- index.html
- "my-critical-image/path/*.{png,jpg}"
runtime_cache:
- route: /img\/embedded\/within\/my\/post
strategy: cacheFirst