Skip to content

Commit

Permalink
fix(plugin): we're handling cache-control (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
bhouston authored Oct 29, 2024
1 parent 3d467eb commit 54fff80
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-pigs-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@mcansh/remix-fastify": patch
---

Make cache-control headers work again.
12 changes: 3 additions & 9 deletions examples/basic/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if (process.env.NODE_ENV === "production") {
prefix: "/",
wildcard: false,
decorateReply: false,
cacheControl: true,
cacheControl: false,
dotfiles: "allow",
etag: true,
serveDotFiles: true,
Expand All @@ -67,18 +67,12 @@ await app.register(fastifyStatic, {
root: BUILD_DIR,
prefix: "/",
wildcard: false,
cacheControl: true,
cacheControl: false,
dotfiles: "allow",
etag: true,
serveDotFiles: true,
lastModified: true,
setHeaders(res, filepath) {
let isAsset = filepath.startsWith(BUILD_DIR);
res.setHeader(
"cache-control",
isAsset ? ASSET_CACHE_CONTROL : DEFAULT_CACHE_CONTROL,
);
},
setHeaders,
});

app.register(async function createRemixRequestHandler(childServer) {
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-fastify/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export const remixFastify = fp<RemixFastifyOptions>(
root: BUILD_DIR,
prefix: basename,
wildcard: false,
cacheControl: true,
cacheControl: false, // required because we are setting custom cache-control headers in setHeaders
dotfiles: "allow",
etag: true,
serveDotFiles: true,
Expand Down

0 comments on commit 54fff80

Please sign in to comment.