chore: sync local workspace changes
This commit is contained in:
@@ -23,6 +23,20 @@ const mimeTypes = {
|
||||
'.woff2': 'font/woff2',
|
||||
};
|
||||
|
||||
function resolveCacheControl(resolvedPath, extension) {
|
||||
const normalizedPath = resolvedPath.replace(/\\/g, '/');
|
||||
|
||||
if (extension === '.html') {
|
||||
return 'no-cache';
|
||||
}
|
||||
|
||||
if (normalizedPath.endsWith('/sw.js') || extension === '.webmanifest') {
|
||||
return 'no-store, no-cache, max-age=0, must-revalidate';
|
||||
}
|
||||
|
||||
return 'public, max-age=31536000, immutable';
|
||||
}
|
||||
|
||||
function looksLikeStaticAsset(requestedPath) {
|
||||
const normalizedPath = requestedPath.split('?')[0] ?? requestedPath;
|
||||
const extension = extname(normalizedPath);
|
||||
@@ -135,7 +149,7 @@ const server = createServer(async (request, response) => {
|
||||
|
||||
response.writeHead(200, {
|
||||
'Content-Type': contentType,
|
||||
'Cache-Control': extension === '.html' ? 'no-cache' : 'public, max-age=31536000, immutable',
|
||||
'Cache-Control': resolveCacheControl(resolvedPath, extension),
|
||||
});
|
||||
|
||||
createReadStream(resolvedPath).pipe(response);
|
||||
|
||||
Reference in New Issue
Block a user