liuderchi / sw-precache-cra

👷 Customize your service worker in create react app without `npm run eject`

Home Page:https://sw-precache-cra-demo-cra-contributors.netlify.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sw-precache-cra - How to exclude files

DevJett opened this issue · comments

Is it possible to ignore a file from caching?
I have a meta.json file including a version of the site and I want the service worker to ignore this file.

My attempt

module.exports = {
    staticFileGlobs: [
        'build/*.html',
        'build/manifest.json',
        'build/static/js/*.js',
        'build/static/css/*.css',
        'build/static/media/**',
    ],
    staticFileGlobsIgnorePatterns: [/\.map$/, /meta\.json$/],
    swFilePath: 'build/service-worker.js',
    stripPrefix: 'build/',
    runtimeCaching: [
        {
            urlPattern: /blog/,
            handler: 'networkFirst'
        }
    ]
}

It does not work.
Can anybody help?