Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mjseyyedi opened this issue Aug 4, 2019 · 1 comment · May be fixed by #459
Closed

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

mjseyyedi opened this issue Aug 4, 2019 · 1 comment · May be fixed by #459

Comments

@mjseyyedi
Copy link

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'); } });

@GGAlanSmithee
Copy link
Collaborator

GGAlanSmithee commented Aug 14, 2019

@mjseyyedi I can see that you solved your own issue reading your SO question - great! :) I sent a PR adding info regarding this, #459, if you have the time, please check it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants