match_callback: 'origin: cdn.jsdelivr.net' not working as expected.
tacman opened this issue · comments
Version(s) affected
1.2.x
Description
I'm moving this from #148 because I think it's a bug or perhaps the documentation can be improved.
- match_callback: 'origin: cdn.jsdelivr.net'
strategy: 'CacheFirst' # or CacheOnly
preload_urls:
- 'https://cdn.jsdelivr.net/npm/onsenui@2.12.8/js/onsenui.min.js'
- 'https://cdn.jsdelivr.net/npm/onsenui@2.12.8/css/ionicons/css/ionicons.min.css'
- 'https://cdn.jsdelivr.net/npm/onsenui@2.12.8/css/onsen-css-components.min.css'
This library never changes, so I really just want to cache it once when the application starts up.
It does not appear that this is working, though, as the other assets show that they are delivered via the service worker, but not the jsdelivr ones.
How to reproduce
Go to
https://pwa-last-stack.survos.com/en/mobile/start
and look at the console network
Possible Solution
No response
Additional Context
No response
Hello @tacman,
Can you try with match_callback: 'origin: https://cdn.jsdelivr.net'
?
It looks like the function is using the scheme as well.
On a related note, I'd like to make sure my s3 urls are cached and/or preloaded. We launched an audio-tour last night, but the exhibition was an old stone building with lousy internet, a perfect application for pre-fetching. There was good internet at the entrance, in the ideal world they'd have gotten all the images and audio at the entrance when they first installed it.
Can you try with
match_callback: 'origin: https://cdn.jsdelivr.net'
?
No, that created lots of errors. Lemme add this to a demo repo that has s3 and jsdelivr urls that need to be cached. Thanks!
What is the difference between workbox-strategy and StrategyHandler?
In this case, I've setup
serviceworker:
enabled: true
src: "sw.js"
skip_waiting: true
workbox:
resource_caches:
- match_callback: 'origin: cdn.jsdelivr.net'
strategy: 'CacheOnly'
preload_urls: # Optional, but you are now sure the library is preloaded even if used on another page the user never met before
- 'https://cdn.jsdelivr.net/npm/onsenui@2.12.8/js/onsenui.min.js'
- 'https://cdn.jsdelivr.net/npm/onsenui@2.12.8/css/ionicons/css/ionicons.min.css'
- 'https://cdn.jsdelivr.net/npm/onsenui@2.12.8/css/onsen-css-components.min.css'
- 'https://cdn.jsdelivr.net/npm/onsenui@2.12.8/css/material-design-iconic-font/fonts/Material-Design-Iconic-Font.woff2?v=2.2.0'
- 'https://cdn.jsdelivr.net/npm/onsenui@2.12.8/css/material-design-iconic-font/css/material-design-iconic-font.min.css'
- 'https://cdn.jsdelivr.net/npm/onsenui@2.12.8/css/font_awesome/webfonts/fa-brands-400.woff2'
Ah, I see, it has to do with the first time it's loaded. OK, not sure why this seems to be working in my test project, I'll keep digging.
What is the difference between workbox-strategy and StrategyHandler?
🤔That's a very good question. but honestly I don't know.
Ah, I see, it has to do with the first time it's loaded. OK, not sure why this seems to be working in my test project, I'll keep digging.
I will give it a try on my side too by tuning the match callback w/o scheme, port or whatsoever.
THis is something I wanted to do, but it can only partially be achieved.
It requires information de profiler cannot have. The callback receives several arguments that are namely:
- The URL
- The request object
- The event
- The params
We only have the Url can easily be converted into an object.
Other values are hard or impossible to guess.
Is it possible that the skip_waiting option is responsible for this behavior?
My pwa.yaml file was created when 1.0 first was in beta, and it's been copied to every project since. But I noticed that you enable it by default now. #59
I'm going to close this, because I'm unable to reproduce it now.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.