hanford / next-offline

make your Next.js application work offline using service workers via Google's workbox
https://github.com/hanford/next-offline
1.59k stars 113 forks source link

Queston: How can I precache a page at `/app`? #262

Open VelinGeorgiev opened 3 years ago

VelinGeorgiev commented 3 years ago

next-offline is a great project and thanks for making our lives so easy!

I am not familiar with the workbook setups, but I am trying to precache additional page at url /app that is to be used by my PWA as homepage instead of /. Is there a way for me to set a precache action it in the next-offline config?

My current setup is pretty basic, but I'd like to also include precache URL /app

 workboxOpts: {
        swDest: 'static/service-worker.js',
        runtimeCaching: [
            {
                urlPattern: /^https?.*/,
                handler: 'NetworkFirst',
                options: {
                    cacheName: 'https-calls',
                    networkTimeoutSeconds: 8,
                    expiration: {
                        maxEntries: 100,
                        maxAgeSeconds: 30 * 24 * 60 * 60 * 2, // 2 months
                    },
                    cacheableResponse: {
                        statuses: [0, 200],
                    },
                },
            },
        ],
    },

I've spend some time on Google before asking this question here, but seems I cannot find the right keywords to get it done.

Thank you!

j3ski-passion commented 3 years ago

@VelinGeorgiev If you are using next-offline@5 you can use the additionalManifestEntries workbox option

VelinGeorgiev commented 3 years ago

Thanks @j3ski-passion ! I will give it a try

kaaax0815 commented 3 years ago

@j3ski-passion @VelinGeorgiev Do you have an example? I dont know how to make this work.