Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tricky-pillows-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-node': patch
---

fix: set no-cache cache-control header for non-immutable assets
13 changes: 7 additions & 6 deletions packages/adapter-node/src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ function serve(path, client = false) {
brotli: true,
setHeaders: client
? (res, pathname) => {
// only apply to build directory, not e.g. version.json
if (
pathname.startsWith(`/${manifest.appPath}/immutable/`) &&
res.statusCode === 200
) {
res.setHeader('cache-control', 'public,max-age=31536000,immutable');
if (res.statusCode === 200 && pathname.startsWith(`/${manifest.appPath}/`)) {
if (pathname.startsWith(`/${manifest.appPath}/immutable/`)) {
// only apply to build directory, not e.g. version.json
res.setHeader('cache-control', 'public,max-age=31536000,immutable');
} else {
res.setHeader('cache-control', 'public,max-age=0,must-revalidate');
}
}
}
: undefined
Expand Down
Loading