Skip to content

Commit

Permalink
fix(adapter-node): only send cache header when static resource is 200 (
Browse files Browse the repository at this point in the history
…#9394)

fixes #9393

---------

Co-authored-by: Ben McCann <[email protected]>
  • Loading branch information
cdemi and benmccann authored Mar 15, 2023
1 parent c45c35e commit e3a336b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/khaki-schools-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/adapter-node': patch
---

fix: only send cache header when static resource is 200
2 changes: 1 addition & 1 deletion packages/adapter-node/src/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function serve(path, client = false) {
client &&
((res, pathname) => {
// only apply to build directory, not e.g. version.json
if (pathname.startsWith(`/${manifest.appPath}/immutable/`)) {
if (pathname.startsWith(`/${manifest.appPath}/immutable/`) && res.statusCode === 200) {
res.setHeader('cache-control', 'public,max-age=31536000,immutable');
}
})
Expand Down

0 comments on commit e3a336b

Please sign in to comment.