Skip to content

clear cache on current users' device in migrating from webpack 3 to 4 #457

@mjseyyedi

Description

@mjseyyedi

Hi.
first of all, thanks for your great plugin.
but then, I asked this question in stackoverflow but nobody answered. the problem is that, when I convert webpack 3 to 4, new service worker cannot detect file changes and clearing cache would not execute. so previous files are still applying. could you help me to find a way in which I could apply changes to new version.

here is my offline-plugin config:
new OfflinePlugin({ relativePaths: false, publicPath: '/', excludes: ['.htaccess'], caches: { main: [], optional: [':rest:'], }, safeToUseOptionalCaches: true, AppCache: false, responseStrategy: 'cache-first', autoUpdate: 1000 * 60 * 60 * 1, appShell:'/index.template.html', ServiceWorker: { output: 'service-worker.js', events: true, prefetchRequest: { credentials: 'include', mode: 'cors' } }, cacheMaps:[ { matchPath: [/^\/\w+\.html$/], to: '/', requestType: ['navigate'] }, ] }),

and this is my updating peace of code:
const runtime = require('offline-plugin/runtime'); runtime.install({ onUpdating: () => { console.log('SW Event:', 'onUpdating'); }, onUpdateReady: () => { console.log('SW Event:', 'onUpdateReady'); runtime.applyUpdate(); }, onUpdated: () => { console.log('SW Event:', 'onUpdated'); window.location.reload(); }, onUpdateFailed: () => { console.log('SW Event:', 'onUpdateFailed'); } });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions