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

Re: @remix-run/serve sets high max-age and immutable cache header on everything #9353

Open
kenteramin opened this issue May 1, 2024 · 2 comments

Comments

@kenteramin
Copy link

Reproduction

  1. Create a remix app
  2. Run build then start
  3. Open the page
  4. Check the headers on the /favicon.ico request

The favicon from /public comes with Cache-Control: public, max-age=31536000, immutable

System Info

remix 2.9.1

Used Package Manager

npm

Expected Behavior

The server config from
https://github.com/remix-run/remix/blob/main/packages/remix-serve/cli.ts
says app.use(express.static("public", { maxAge: "1h" }));.
So it is expected to have maxAge=1h

Actual Behavior

We actually get an immutable maxAge=1y

@kenteramin
Copy link
Author

There was already a bug of the same nature
#903

@kenteramin
Copy link
Author

So, actually the problem is that here

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

build.assetsBuildDirectory is just build/client, so it handles all the requests to the public folder.

The config should actually be something like this

app.use(
  build.publicPath,
  express.static(build.assetsBuildDirectory + "/assets", {
    immutable: true,
    maxAge: "1y",
  })
);
app.use(express.static(build.assetsBuildDirectory, { maxAge: "1h" }));

@kenteramin kenteramin changed the title Re: @remix-run/serve sets high max-age and immutable cache header on everything Re: @remix-run/serve sets high max-age and immutable cache header on everything May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants