Repository navigation
fix(caddy): exempt hashed assets from rate limit and cache them immutably - #63
Merged
Merged
Conversation
…ably The per-IP limiter covered every request, so a post-deploy page load revalidating ~400 chunks behind a shared office IP hit 429. Hashed assets now skip the limiter and get a one-year immutable Cache-Control; HTML documents get no-cache.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
pm.for about 50 seconds after loading a page. Part of FOSS-840, train FOSS-838.rate_limitof 300 requests per minute with no path matcher, and hashed assets are served withoutCache-Control. After a deploy the browser revalidates about 400 chunks per page load (304s count), crosses 300/min, and the next document request gets 429. The whole office shares one egress IP, so one user's reload can block colleagues. Prod still runs nginx (v1.4.3), so this would have reached prod with the v26.11.3 promotion. Upstreampreviewhas no fix.apps/web/caddy/Caddyfileandapps/admin/caddy/Caddyfile(admin uses/god-mode/assets/*):assets/[name]-[hash]; nothing copied verbatim frompublic/lands under/assets.no-cache, so a deploy is picked up on the next load. A missing/assets/<name>falls back toindex.html, getsno-cacheand stays rate-limited (the limiter runs aftertry_files, per upstream'sorder rate_limit before file_server).{client_ip}) for every other path.index.htmlwith 200 instead of 404.Testing
caddy:2.11.7-builder-alpine+xcaddy --with github.com/mholt/caddy-ratelimit):caddy validatepasses for both files/,/index.html, SPA routes and missing assets returnno-cache; existing/assets/*returnpublic, max-age=31536000, immutable; 500 rapid asset requests all 200; 320 requests to/give 296 x 200 and 24 x 429/god-mode/and SPA routesno-cache,/god-mode/assets/*immutable and exemptAI disclosure