Node.js, Express & HTTP
Trace requests, understand the runtime, and build reliable APIs.
Which HTTP status codes should I know?
An HTTP status code describes the outcome of an HTTP request using a standard numeric category. Clients use it to decide whether to use a result, correct a request, authenticate or retry. A response body can add application details, but should not contradict the status code.
PUT vs PATCH, and what does idempotent mean?
PUT is defined around creating or replacing the state of a target resource, while PATCH applies a described partial change. Idempotency means repeating an identical operation has the same intended server-side effect as doing it once. It does not require every repeated response to contain the same status or body.
HTTP/1.1 vs HTTP/2 vs HTTP/3?
HTTP versions preserve the basic request/response model but change how messages travel over the network. HTTP/2 multiplexes streams over one TCP connection, while HTTP/3 uses QUIC to avoid some transport-level blocking between streams. These improvements affect connection efficiency, not the need for correct API semantics.
How do cookies and sessions work?
A cookie is a small piece of browser-managed data sent automatically with matching requests. A server-side session uses an unpredictable identifier, often in a cookie, to look up login state on the server. This lets the server revoke or change that state without placing all session details in the browser.
What is CORS? Does it protect an API from all clients?
CORS is a browser-enforced protocol that lets a server permit selected cross-origin response access. The browser checks response headers and may send a preflight request before the actual request. It is not a firewall: clients outside the browser can still call the API, and some cross-origin requests can be sent even without readable responses.
How do ETag and caching work?
HTTP caching reuses a stored response when its cache rules allow it, reducing repeated work and data transfer. An ETag identifies a resource representation so the client can ask whether its saved version is still valid. Conditional requests allow the server to say “unchanged” without sending the full representation again.
How should pagination and API versioning work?
Pagination divides a large result set into manageable pages, while API versioning lets an interface change without unexpectedly breaking clients. Both are part of the API contract because callers depend on ordering, limits and field meaning. A good design remains predictable as the data and number of clients grow.
Difficulty is an editorial estimate. Completion means you chose to mark a question as understood.