Merge pull request #429 from nolanlawson/consistent-cache-control

Use consistent cache-control:max-age=600 for HTML pages
This commit is contained in:
Rich Harris
2018-09-08 09:40:56 -04:00
committed by GitHub
2 changed files with 11 additions and 4 deletions

View File

@@ -136,7 +136,7 @@ export default function middleware(opts: {
fs.existsSync(path.join(output, 'index.html')) && serve({
pathname: '/index.html',
cache_control: 'max-age=600'
cache_control: dev() ? 'no-cache' : 'max-age=600'
}),
fs.existsSync(path.join(output, 'service-worker.js')) && serve({
@@ -312,6 +312,7 @@ function get_page_handler(
} = get_build_info();
res.setHeader('Content-Type', 'text/html');
res.setHeader('Cache-Control', dev() ? 'no-cache' : 'max-age=600');
// preload main.js and current route
// TODO detect other stuff we can preload? images, CSS, fonts?