Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: @remix-run/serve sets high max-age and immutable cache header on everything #903

Closed
1 of 12 tasks
sheepsteak opened this issue Dec 5, 2021 · 1 comment
Closed
1 of 12 tasks
Labels
bug Something isn't working

Comments

@sheepsteak
Copy link

Which Remix packages are impacted?

  • remix (Remix core)
  • create-remix
  • @remix-run/architect
  • @remix-run/cloudflare-workers
  • @remix-run/dev
  • @remix-run/express
  • @remix-run/netlify
  • @remix-run/node
  • @remix-run/react
  • @remix-run/serve
  • @remix-run/server-runtime
  • @remix-run/vercel

What version of Remix are you using?

1.0.4

What version of Node are you using? Minimum supported version is 14.

16.13.0

Steps to Reproduce

  • Build and start an application in production that has some resources in the public (remix blog)
  • See in dev tools that everything in public folder is served with a high max-age and immutable

image

Expected Behavior

Only files in public/build should have long, immutable caching as they are fingerprinted. The express starter template separates the two (although it has issues with the ordering of express.static as shown in #677 and fixed in #678):

// You may want to be more aggressive with this caching
app.use(express.static("public", { maxAge: "1h" }));
// Remix fingerprints its assets so we can cache forever
app.use(express.static("public/build", { immutable: true, maxAge: "1y" }));

Files in the base public folder should have a low max-age of 1h like elsewhere so that favicons, images, fonts, etc. can be updated as needed.

Actual Behavior

Due to this line everything in public gets the same cache headers:

app.use(express.static("public", { immutable: true, maxAge: "1y" }));

This is fine for the built application files in public/build as they are fingerprinted but not for resources like favicon.icothat might need to change.

@sheepsteak sheepsteak added the bug Something isn't working label Dec 5, 2021
ch4nd4n added a commit to ch4nd4n/remix that referenced this issue Dec 9, 2021
Fixes issue raised remix-run#903 by introducing ENV variable REMIX_SERVE_MAX_AGE
@machour machour linked a pull request Apr 12, 2022 that will close this issue
@mcansh
Copy link
Collaborator

mcansh commented May 2, 2022

hey @sheepsteak this was fixed in #2363 and released in v1.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants