-
Notifications
You must be signed in to change notification settings - Fork 7
Bring the docs in line with the tracked origin config #1587
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| # Nginx Cache Alignment | ||
|
|
||
| Nginx (`ssrcache` zone) sits between the CF worker and vision_web. It runs | ||
| on each origin server (eu/us/asia.ecency.com). Because the worker has | ||
| Nginx (`ssrcache` zone) sits between the CF worker and vision_web. It runs on each | ||
| origin server (EU and US; the asia origin was decommissioned). Because the worker has | ||
| already keyed on auth-class and only forwards cacheable requests, **nginx | ||
| does NOT need to gate on `active_user` cookie itself** — origin's | ||
| `Cache-Control` is the source of truth. | ||
|
|
@@ -25,45 +25,33 @@ proxy_cache_path /var/cache/nginx/ssr levels=1:2 | |
|
|
||
| ## Per-host config | ||
|
|
||
| ⛔ **The vhosts are tracked: read `infra/origin/eu.ecency.com.conf` and | ||
| `us.ecency.com.conf` rather than a snippet here.** This section used to carry a | ||
| hand-copied `server { … }` block, which drifted and began contradicting the real config | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Removing the Useful? React with 👍 / 👎.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed and fixed in fa62b35. This was a real break and my judgement was wrong. I read the whole The map had not drifted, and is duplicated because it is enforced. The part that should have stopped me: I wrote the invariant into my replacement text ("must stay in step with Restored, under a heading that says so rather than leaving the next reader to make the same call:
The stale Verified:
greptile-apps[bot] marked this conversation as resolved.
Outdated
|
||
| — it showed `add_header X-Cache-Tier $upstream_http_x_cache_tier always;`, which the | ||
| tracked file explicitly forbids because the upstream already sets that header and nginx | ||
| proxies it through, so adding it emitted the header **twice on every response**. It also | ||
| showed `always` on `X-Cache-Status`, which the real config deliberately omits: that value | ||
| is a cache diagnostic, not something we owe an error response. | ||
|
|
||
| What matters conceptually, and is stable: | ||
|
|
||
| ```nginx | ||
| # See "Why the bot UA class is in the cache key" below. | ||
| map $http_user_agent $html_limited_bot { | ||
| default ""; | ||
| "~*(Googlebot|[\w-]+-Google|Google-[\w-]+|googleweblight|Chrome-Lighthouse|Slurp|DuckDuckBot|baiduspider|yandex|sogou|bitlybot|tumblr|vkShare|quora link preview|redditbot|ia_archiver|Bingbot|BingPreview|applebot|facebookexternalhit|facebookcatalog|Twitterbot|LinkedInBot|Slackbot|Discordbot|TelegramBot|WhatsApp|SkypeUriPreview|Yeti)" "|htmlbot"; | ||
| } | ||
|
|
||
| server { | ||
| listen 80; | ||
| server_name eu.ecency.com; # or us per host | ||
|
|
||
| location / { | ||
| proxy_cache ssrcache; | ||
| proxy_cache_key "$request_uri$html_limited_bot"; | ||
| # Defer to origin Cache-Control. Fallback for responses without it. | ||
| proxy_cache_valid 200 0; | ||
| proxy_cache_valid any 30s; | ||
| # Stale-while-revalidate semantics | ||
| proxy_cache_use_stale updating error timeout http_500 http_502 http_503 http_504; | ||
| proxy_cache_background_update on; | ||
| proxy_cache_lock on; | ||
| proxy_cache_lock_timeout 5s; | ||
|
|
||
| # Observability | ||
| add_header X-Cache-Status $upstream_cache_status always; | ||
| add_header X-Cache-Tier $upstream_http_x_cache_tier always; | ||
|
|
||
| proxy_pass http://127.0.0.1:3000; | ||
| proxy_set_header Host $host; | ||
| proxy_set_header X-Real-IP $remote_addr; | ||
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| proxy_set_header X-Forwarded-Proto $scheme; | ||
| proxy_connect_timeout 5s; | ||
| proxy_send_timeout 20s; | ||
| proxy_read_timeout 20s; | ||
| } | ||
| } | ||
| proxy_cache ssrcache; | ||
| proxy_cache_key "$request_uri$html_limited_bot"; # see the next section | ||
| proxy_cache_valid 200 0; # defer to origin Cache-Control | ||
| proxy_cache_valid any 30s; | ||
| proxy_cache_use_stale updating error timeout http_500 http_502 http_503 http_504; | ||
| proxy_cache_background_update on; | ||
| proxy_cache_lock on; | ||
| ``` | ||
|
|
||
| The `$html_limited_bot` map lives at `http` level in `/etc/nginx/nginx.conf`, which is | ||
| **not** tracked (see `infra/origin/README.md`, "What these files depend on"). Its pattern | ||
| list must stay in step with `htmlLimitedBots` in `next.config.js`: if the app serves a | ||
| blocking render to an agent the map does not classify, that response and a browser's | ||
| share one cache entry. | ||
|
|
||
| ## Why the bot UA class is in the cache key | ||
|
|
||
| `htmlLimitedBots` in `apps/web/next.config.js` makes Next.js render metadata | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the slim-entry audit finds a violation, this documented command still exits successfully because
scripts/slim-entries-audit.mjsonly returns status 1 when--failis present. Anyone following this new audit checklist can therefore miss the feed-payload violations that CI rejects; add--failhere to match the workflow command.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both correct, fixed in fa62b35.
slim-entries-audit.mjsonly exits 1 with--fail, so the command as I wrote it would report violations and exit 0 — the worst shape for a checklist, since it passes locally and fails in CI. And the heading said "Three" while listing four.Now matched to
typecheck.ymlline for line, with the flags called out rather than left to be noticed:with "⛔ Copy the flags exactly: without
--failthese REPORT and exit 0, so a violation passes locally and fails in CI."Ordered as CI runs them, and
icon-scss-auditdeliberately has no flag because that is how the workflow invokes it.