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

feat(pgs): Configure cache-control, TTL, max body, exclude /check #176

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

mac-chaffee
Copy link
Contributor

  • Increased the default TTL from 5 minutes to 10 minutes.
    • Reason: Sounds like the cache clearing has been working so we should be safe to raise it. 10 minutes is the default max-age for all Github Pages sites so it's probably a good standard to match.
  • Made the default TTL configurable
  • Set the default Cache-Control header to max-age: 600
    • Reason: Right now, the default value is set to the empty string, which is under-specified, but generally interpreted as if the header were missing. If the header is missing, browsers will still cache content on the client-side, but without an explicit TTL they will use a heuristic for calculating their own TTL (typically 10% of the time since the Last-Modified date). Explicitly setting the TTL is recommended instead of relying on that.
  • Set the maximum cacheable body size.
    • In Implement caching using Souin (take 2) #159 I originally set this to 1MB but I was lazy and didn't want to add another config value so I just set it to the current max file size of 10MB :) Beware of RAM-based DDoS! May want to set a RAM limit on your pgs container in docker-compose.
  • Excluded /check from caching.
    • Reason: Currently Souin is not caching /check anyway, but only because of UPSTREAM-ERROR-OR-EMPTY-RESPONSE, so I just made this more explicit.

PS: Thanks for the shout-out in the caching blog post!

Copy link
Member

@neurosnap neurosnap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I'll add a RAM cap to pgs-web thanks for that call out.

@neurosnap neurosnap merged commit 6886a8e into picosh:main Dec 17, 2024
3 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants