From 5ee53a98c6c3c09f9069be3851c92a590dfd4961 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Fri, 7 Sep 2018 16:28:38 -0700 Subject: [PATCH 1/2] set service-worker max-age to 0 --- src/middleware.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/middleware.ts b/src/middleware.ts index bab65364f..20102ac0b 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -141,12 +141,12 @@ export default function middleware(opts: { fs.existsSync(path.join(output, 'service-worker.js')) && serve({ pathname: '/service-worker.js', - cache_control: 'max-age=600' + cache_control: 'max-age=0' }), fs.existsSync(path.join(output, 'service-worker.js.map')) && serve({ pathname: '/service-worker.js.map', - cache_control: 'max-age=600' + cache_control: 'max-age=0' }), serve({ From cbb5e8755ba8955061b289afdca9c278ee4be694 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 8 Sep 2018 10:12:55 -0400 Subject: [PATCH 2/2] Use MDN recommendation for preventing SW caching --- src/middleware.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/middleware.ts b/src/middleware.ts index 20102ac0b..755efb512 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -141,12 +141,12 @@ export default function middleware(opts: { fs.existsSync(path.join(output, 'service-worker.js')) && serve({ pathname: '/service-worker.js', - cache_control: 'max-age=0' + cache_control: 'no-cache, no-store, must-revalidate' }), fs.existsSync(path.join(output, 'service-worker.js.map')) && serve({ pathname: '/service-worker.js.map', - cache_control: 'max-age=0' + cache_control: 'no-cache, no-store, must-revalidate' }), serve({