Skip to content

rewrite static middleware to correctly set headers #3089

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

Merged
merged 1 commit into from
May 27, 2024

Conversation

haarg
Copy link
Member

@haarg haarg commented May 26, 2024

Surrogate-Control headers were being set for 404 responses for static files. This would cause Fastly to cache them indefinitely. During a deploy, there would be a period of time where new servers would link to js and css assets, which old servers would respond with 404s and get cached.

Fix the static file serving code to only set the Surrogate-Control headers for 2xx responses to prevent this. This ended up being a significant rewrite of the middleware.

Surrogate-Control headers were being set for 404 responses for static
files. This would cause Fastly to cache them indefinitely. During a
deploy, there would be a period of time where new servers would link to
js and css assets, which old servers would respond with 404s and get
cached.

Fix the static file serving code to only set the Surrogate-Control
headers for 2xx responses to prevent this. This ended up being a
significant rewrite of the middleware.
Copy link

codecov bot commented May 26, 2024

Codecov Report

Attention: Patch coverage is 89.18919% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 72.91%. Comparing base (61168a1) to head (7dbbae4).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3089      +/-   ##
==========================================
+ Coverage   72.50%   72.91%   +0.40%     
==========================================
  Files          69       69              
  Lines        2379     2385       +6     
  Branches      334      336       +2     
==========================================
+ Hits         1725     1739      +14     
+ Misses        529      520       -9     
- Partials      125      126       +1     
Files Coverage Δ
lib/MetaCPAN/Web.pm 88.88% <ø> (ø)
lib/MetaCPAN/Middleware/Static.pm 85.71% <89.18%> (+7.71%) ⬆️

... and 1 file with indirect coverage changes

@haarg haarg merged commit 833a92f into master May 27, 2024
11 checks passed
@haarg haarg deleted the haarg/static-rewrite branch May 27, 2024 16:17
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