主题: http
-
HTTP-Statuscodes richtig verwenden: die erste Verzweigung des Clients
Clients, Caches und Agenten entscheiden allein am Statuscode über Wiederholen, Neuladen oder Aufgeben: 201/204 für Erfolg mit und ohne Körper, 401 gegen 403 für fehlende Anmeldung gegen fehlende Berechtigung, 409/412/428 für Konflikte und Vorbedingungen, 429 und 503 mit Retry-After für «später». Ein 200 mit Fehlerobjekt täuscht alle.
-
Honor Retry-After as a lower bound
Schedule retries from either form of Retry-After while preserving the task deadline and avoiding premature repeated requests.
-
Backing off as a client: Retry-After, RateLimit headers and per-host budgets
How an agent should react to 429 and 503 responses and to advisory rate-limit headers: honour Retry-After exactly, otherwise back off exponentially with jitter, read the RateLimit and RateLimit-Policy fields where a server sends them to pace ahead of the limit, keep a budget per host and per key, and never retry a non-idempotent write without an idempotency key.
-
响应压缩:在哪一层做,排除哪些内容
在代理或应用中压缩文本响应(HTML、JSON、Markdown),跳过已压缩和流式内容,确保不同编码下的 ETag 如实对应表示,并设置 Vary: Accept-Encoding。
-
Verteiltes Tracing in Umrissen: Spans, Eltern-Kennungen und W3C Trace Context
Ein Trace ist ein Baum aus Spans, jeder mit Trace-Kennung, eigener Span-Kennung, Eltern-Span-Kennung, Zeitstempeln, Attributen und Status; der W3C-Header traceparent trägt Trace-Kennung, Eltern-Kennung und ein Sampled-Flag über Prozessgrenzen, und ein Dienst, der beide Header nur weiterreicht, hält Traces trotzdem zusammen.
-
Custom 404 pages and soft 404s: serve the error page with the error status
A custom 404 page helps users only if it is served with status 404; a not-found page served with 200 is a soft 404 that crawlers keep fetching and search engines exclude. nginx's error_page can rewrite the status (error_page 404 =200 ...), which is exactly how soft 404s are created by accident; keep the status, make the page useful, and check with curl -I.
-
同源策略:源是什么,以及它隔离什么
源由 URL 的协议方案、主机和端口组成。脚本可以读取和修改同源文档、存储及响应;跨源读取默认被阻止,而表单提交等跨源写入,以及图片和脚本等嵌入通常被允许。CORS 放宽读取限制,但仍需 CSRF 防御。
-
Using fetch with timeouts and AbortController
A fetch promise rejects only on network failure, not on HTTP error status, and it has no timeout by itself. Pass an AbortSignal combined from AbortSignal.timeout and a caller's controller, check response.ok, and tell TimeoutError, AbortError, network errors and HTTP errors apart in the catch.
-
Idempotente Operationen und sichere Wiederholungen entwerfen
Eine Operation ist idempotent, wenn ihre mehrfache Ausführung dieselbe Wirkung hat wie eine einzelne; RFC 9110 legt das für HTTP-Methoden fest, und ein Idempotency-Key-Header überträgt die Eigenschaft auf POST. Schlüssel samt Fingerabdruck und Ergebnis speichern, Konflikte mit 409 und 422 melden, Schlüssel nach dokumentierter Frist löschen.
-
Server-Sent Events 与 WebSocket 的比较
Server-Sent Events 通过普通 HTTP 将文本事件从服务器持续发送给客户端,并支持自动重连和最后事件标识;WebSocket 则使用自己的协议,提供支持二进制数据的双向通道。单向更新可选择 SSE,客户端需要频繁发送数据时可选择 WebSocket。
-
Calling the TypeSafe API from an agent: request shape, errors, retries and version pinning
The documented contract an agent needs to call Jev without a chat layer: POST /v1/systemone with a Bearer key, a state, a model name and a map of typed questions; answers keyed like the questions plus a usage block; 401, 422, 429 and 529 with exponential backoff; aliases that move and versioned IDs that do not; SDK defaults for retries and the agent skill for coding agents.
-
Link 标头与链接关系类型
RFC 8288 允许任何 HTTP 响应在 Link 标头中携带带类型的链接:<target>; rel="relation",并可附加 anchor、hreflang、type、title 和 media 参数。关系名来自 IANA 注册表,例如 next、prev、canonical、alternate、describedby、preload;私有扩展则使用绝对 URI。非 HTML 响应由此可以指向相邻资源,103 Early Hints 也借此告诉浏览器应提前获取什么。
-
Web Push basics: subscriptions, VAPID keys and the push service
A browser subscribes with its vendor's push service and hands the page an endpoint plus keys; the application server POSTs encrypted messages to that endpoint with a TTL header and a VAPID JWT (ES256, aud = push service origin, exp at most 24 hours) whose public key was passed to PushManager.subscribe as applicationServerKey. A 201 means accepted, not delivered.
-
Sitemaps und kanonische Adressen: ein Inhalt, eine Adresse
Jeder Inhalt sollte genau eine kanonische HTTPS-Adresse haben, die auf der Seite selbst erklärt wird; Zwillinge wie Markdown- oder JSON-Fassungen verweisen per Link-Header darauf, Parameter ohne Inhaltswirkung erzeugen keine neuen Adressen, und die Sitemap listet nur kanonische Adressen mit wahren Änderungsdaten.
-
HEAD 与 OPTIONS:回答什么,客户端如何使用
HEAD 相当于不带响应体的 GET:状态和标头相同,但可以省略 Content-Length 和 Vary。它可缓存,用于链接检查、大小探测和新鲜度检查。OPTIONS 查询资源或整个服务器(OPTIONS *)支持的通信选项,通常以 Allow 回答,不可缓存,也用于携带 Access-Control-Request-Method 的 CORS 预检。
-
URL shortener walk-through: key generation, redirect status and abuse controls
A design walk-through for a URL shortener: random base62 keys with collision retry, a redirect path that touches one cache and one store, 302 rather than 301 when targets must stay revocable and countable, creation-side abuse checks, and a list of what not to build first.
-
Collapsing redirect chains to single hops raises the share of crawler requests that end in a 200 on a large site
Hypothesis: on a site with tens of thousands of URLs and accumulated redirects, rewriting every chain so that each old URL answers with one redirect to its final target measurably increases the share of search-crawler requests that reach a 200 page within a fixed daily request volume, because crawlers spend requests on each hop; a proposed before-and-after test on server logs.
-
JSON Web Tokens: what can go wrong and RFC 8725's answers
JWTs are signed claims, not encrypted secrets; validate the algorithm against an allowlist, verify issuer, audience and expiry, keep lifetimes short, never accept 'none', and remember that a stateless token cannot be revoked without a server-side list.
-
Bulk endpoints and partial failure reporting
A bulk endpoint either succeeds or fails as a whole or reports per-item outcomes; a single 200 cannot express partial success, so choose one behaviour per endpoint, index failures by position, cap batch size, and apply authorisation and rate limits per item.
-
有意识地选择 HTTP 状态码
状态码是客户端首先用来选择处理分支的信息:200/201/204 表示成功,304 表示未修改,400/422 表示输入有误,401/403 分别涉及凭据与权限,404 表示不存在,409/412/428 涉及冲突与前置条件,429/503 表示稍后再试。
机器可读: JSON