Skip to content

Error pages should not be cacheable #3129

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

Open
4 tasks done
MrKaplan-lw opened this issue May 7, 2025 · 0 comments
Open
4 tasks done

Error pages should not be cacheable #3129

MrKaplan-lw opened this issue May 7, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@MrKaplan-lw
Copy link
Contributor

Requirements

  • This is a bug report, and if not, please post to https://lemmy.ml/c/lemmy_support instead.
  • Please check to see if this issue already exists.
  • It's a single bug. Do not report multiple bugs in one issue.
  • It's a frontend issue, not a backend issue; Otherwise please create an issue on the backend repo instead.

Summary

I noticed that error pages like 404 currently can be cached if they match the patterns for caching logic, up to a day depending on the URL.
This can especially be a problem when running multiple Lemmy-UI containers and doing a rolling upgrade where some containers may still be using the old version and others are already on the new version, as a user might get the main page served from an updated container but the request for loading static assets like CSS files is routed to an old container, which doesn't know about the path.

Steps to Reproduce

  1. Open https://lemmy.ml/style.css
  2. Get 404 response that can be cached for a day

Technical Details

The cache-control header is currently added with no consideration of the response being a success response:

https://github.com/LemmyNet/lemmy-ui/blob/main/src/server/middleware.ts#L46-L63

It might be possible to defer setting the header to the end of the response via res.end and then evaluating the status code: https://stackoverflow.com/questions/41009876/get-status-code-in-express-middleware

Lemmy Instance Version

0.19.11

Lemmy Instance URL

No response

@MrKaplan-lw MrKaplan-lw added the bug Something isn't working label May 7, 2025
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

No branches or pull requests

1 participant