HTTP-методы несут контракт (safe, idempotent, cacheable); status codes — grouped verdict; headers — caching, auth, negotiation, CORS. Break contract — phantom writes и wrong retries.
Разбор
Methods — contract, not guarantee. Ничто не запрещает GET мутировать БД — но ecosystem (browser, CDN, retry libs) assumes safe GET. CDN replay cached GET; browser prefetch; retry idempotent PUT after timeout.
Status codes по первой цифре:
- 2xx — success.
200, 201 Created (+ Location), 204 No Content.
- 3xx — redirect.
301 permanent (hard cache), 302/307 temporary. 304 — cache validation win.
- 4xx — client fault.
400, 401 unauthenticated, 403 unauthorized, 404, 409, 422, 429.
- 5xx — server fault.
500, 502, 503, 504.
401 vs 403 — classic tell: 401 = «log in», 403 = «login не поможет».
Headers. Content-Type — format body; Accept — content negotiation. Authorization — credential. Cache-Control, ETag + If-None-Match — conditional requests. Origin, Access-Control-* — browser-only CORS machinery.
Итог
Senior skill — знать contracts методов и различать 401/403/409/422; headers решают cache, auth и format.