Open kaiwenxiao opened 2 years ago
It worked for me:
config:
"cache": { "runtimeCaching": [ { "urlPattern": "http://localhost:1234/cache.jpg", "handler": "staleWhileRevalidate", "options": { "broadcastUpdate": { "channelName": "api-updates" } } } ] }
index.js
const updatesChannel = new BroadcastChannel('api-updates'); updatesChannel.addEventListener('message', event => { console.log(event); });
index.html contained <img src="http://localhost:1234/cache.jpg">. Changing out cache.jpg fires the eventlistener.
<img src="http://localhost:1234/cache.jpg">
Did you use staleWhileRevalidate?
staleWhileRevalidate
Originally posted by @mischnic in https://github.com/mischnic/parcel-plugin-sw-cache/issues/4#issuecomment-371230274
I give my API response updated, which will trigger this listener, and also skipWaiting() then refresh broswer
skipWaiting()
It worked for me:
config:
index.js
index.html contained
<img src="http://localhost:1234/cache.jpg">
. Changing out cache.jpg fires the eventlistener.Did you use
staleWhileRevalidate
?Originally posted by @mischnic in https://github.com/mischnic/parcel-plugin-sw-cache/issues/4#issuecomment-371230274