Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images Not Caching #5

Open
mswbull opened this issue Feb 2, 2018 · 1 comment
Open

Images Not Caching #5

mswbull opened this issue Feb 2, 2018 · 1 comment
Assignees

Comments

@mswbull
Copy link

mswbull commented Feb 2, 2018

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?

@xiaoiver
Copy link
Contributor

xiaoiver commented Feb 6, 2018

I think there're two options to cache images with Google Workbox:

  1. 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.
  2. 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

@xiaoiver xiaoiver self-assigned this Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants