1

I am creating a progressive web app using service workers and i am using service worker toolbox to cache my content. Service worker code to cache my content :

toolbox.router.get('/(.)', toolbox.fastest);
toolbox.router.post('/(.)', toolbox.fastest);
toolbox.router.get('/(.)', toolbox.fastest, {origin: 'https://example.cloudfront.net'})
toolbox.router.get('/(.)', toolbox.fastest, {origin: 'https://example.in'})

The code is running fine as i am not seeing any error in the console. But how can i check whether the images from cloudfront or the url's configured above are getting cached and rendered from the cache itself.

3 Answers 3

4

You can check the cache content in chrome devtools, look in the resources / application tab and cache storage.

You check it's returned, look in devtools network panel and look for '(from ServiceWorker)' in the size column.

3
  • I believe, Its not sure shot way to find if file is coming from cache. What if the strategy is Network First.You will always see 'from service worker' in size column of dev tools. Commented May 29, 2016 at 13:47
  • Hi Gaunt, thankyou for the reply. So, when i am pre caching my files then i am able to see all the files which are cached in the resource tab( dev tools resource panel) under cache. But when it comes to runtime caching, would i be able to see the files in resource tab ? Commented May 30, 2016 at 8:48
  • Yeah you can see run time assets there as well
    – Matt Gaunt
    Commented May 31, 2016 at 5:26
0

One more option is if you want to confirm then you should use console.log() in the function from where you are getting the cache data then you can check in DevTools.

0

You can check it in Chrome Developers Tool

Press F12 -> Application -> Cache Storage in Cache

If you are not able to see it, Refresh Cache Storage by doing right click on cache storage.

Not the answer you're looking for? Browse other questions tagged or ask your own question.