So i've built a website with a vue.js. It's deployed on AWS s3 bucket that lies behind a CloudFront distribution. Recently i've found out that some users are seeing 2 week old version of the website. This is a big issue since i am updating website few times daily.
I've placed CloudFront TTL setting to 1 minute in order to try and avoid longer caching but that didn't resolve issues. I tried implementing service worked in following way which threw many exceptions and didn't work.
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('/sw.js').then(function(registration) {
// Registration was successful
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, function(err) {
// registration failed :(
console.log('ServiceWorker registration failed: ', err);
});
});
}
I've tried disabling cache completely as well but it didn't work:
module.exports = {
chainWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.module.rule('vue').uses.delete('cache-loader');
config.module.rule('js').uses.delete('cache-loader');
config.module.rule('ts').uses.delete('cache-loader');
config.module.rule('tsx').uses.delete('cache-loader');
}
}
}
I want to be able to represent a completely fresh content on website and not let it cache for weeks....