diff --git a/server/routes.js b/server/routes.js index 5881895b..ac038ba1 100644 --- a/server/routes.js +++ b/server/routes.js @@ -19,14 +19,14 @@ const router = new Router(); // } // }); -if (process.env.NODE_ENV === 'production') { - router.get('/service-worker.js', async (ctx) => { - ctx.set('Content-Type', 'application/javascript'); - ctx.set('Cache-Control', `max-age=${30}`); - const stats = await sendfile(ctx, path.join(__dirname, './static/service-worker.js')); - if (!ctx.status) ctx.throw(httpErrors.NotFound()); - }); +router.get('/service-worker.js', async (ctx) => { + ctx.set('Content-Type', 'application/javascript'); + if (process.env.NODE_ENV === 'production') ctx.set('Cache-Control', `max-age=${30}`); + await sendfile(ctx, path.join(__dirname, './static/service-worker.js')); + if (!ctx.status) ctx.throw(httpErrors.NotFound()); +}); +if (process.env.NODE_ENV === 'production') { router.get('/static/*', async (ctx) => { ctx.set({ 'Cache-Control': `max-age=${356*24*60*60}`, diff --git a/server/static/dev.html b/server/static/dev.html index 091e809c..fe8cbbb4 100644 --- a/server/static/dev.html +++ b/server/static/dev.html @@ -29,5 +29,15 @@ + diff --git a/server/static/service-worker.js b/server/static/service-worker.js index 4dbe6be1..7b835e75 100644 --- a/server/static/service-worker.js +++ b/server/static/service-worker.js @@ -1,3 +1,5 @@ +/* eslint-disable */ + /* Copyright 2014 Google Inc. All Rights Reserved. @@ -52,6 +54,7 @@ Cache.prototype.addAll||(Cache.prototype.addAll=function(t){function e(t){this.n // Assets global.toolbox.router.get(/\/static\//, global.toolbox.cacheFirst); + global.toolbox.router.get('/(.*)', global.toolbox.fastest, {origin: 'https://secure.gravatar.com'}); // API GET calls global.toolbox.router.default = global.toolbox.networkFirst;