kevinmarrec / nuxt-pwa-module

⚠️ DEPRECATED ⚠️ Zero config PWA solution for Nuxt 3
MIT License
338 stars 32 forks source link

runtimeCaching option #16

Closed desaintflorent closed 1 year ago

desaintflorent commented 2 years ago

Hi there, I'm using the runtimeCaching option with workbox because my images are from a different domain. I can see that workbox extra options are not supported for this module, could I use this module and still cache images from different domain ?

kevinmarrec commented 2 years ago

Hi @desaintflorent , what would you need as configuration to achieve your goal ? Would you have a piece of code of the resulting worker file you want to have it working ?

desaintflorent commented 2 years ago

That is what I'm using right now with the official nuxt pwa module :

workbox: {
        suffix: "v1",
        runtimeCaching: [
            {
                urlPattern: "http://domain.com/api/.*",
                handler: "networkFirst",
                method: "GET",
                strategyOptions: {
                    cacheName: "api",
                    cacheableResponse: { statuses: [0, 200] },
                },
            },
            {
                urlPattern: "http://files.domain.com/.*",
                handler: "staleWhileRevalidate",
                strategyOptions: {
                    cacheName: "images",
                    cacheExpiration: {
                        maxEntries: 30,
                        maxAgeSeconds: 300, //60 * 60// 1h
                    },
                    cacheableResponse: { statuses: [0, 200] },
                },
            },
        ],
    },
kevinmarrec commented 2 years ago

Great, I'll work on this. Do you need the suffix option too ? I'm not sure what it does but I can anyway check official Nuxt 2 PWA module code.

kevinmarrec commented 1 year ago

@desaintflorent I'm gonna add support for custom workbox template in which you'll be able to fully customize your runtime caching.

We may add module options later on but I want first to provide a way to fully customize the worker with own template first.

desaintflorent commented 1 year ago

Ok great ! keep me updated 🙌