0

I am updating my website to PWA, and I am using google workbox as service worker to cache data. I can cache JS, images css etc, but I can't cache back4app query data.

I tried to use workbox.backgroundSync, but when I check in IndexDB, it cache nothing. Here is my code:

const bgSyncPlugin = new workbox.backgroundSync.Plugin('myQueueName', 
{
     maxRetentionTime: 24 * 60 // Retry for max of 24 Hours
});

workbox.routing.registerRoute(
      'https://parseapi.back4app.com/classes/*',
      workbox.strategies.networkOnly({
      plugins: [bgSyncPlugin]
   }),
   'POST'
);

1) Is it possible to cache back4app data using workbox?

2) If possible, how do I do it? Can you give me an example of the code? I have tried for two days but didn't succeed. Thanks.

Alexey
  • 5,898
  • 9
  • 44
  • 81
nacheal
  • 1
  • 1

1 Answers1

0

There's a npm module called "workbox-build" and it can be installed at the cloud code. If you install it and follow its guides, it will probably work as expected. :)

Charles
  • 531
  • 2
  • 11