HTTP interview questions and answers: the protocol under every web app

HTTP interview questions check whether you know what actually travels between a client and a server: how a message is framed, what each header tells caches and proxies, how a body's length is known, and why a response was or was not served from cache. Fresher rounds ask about methods, headers and cookies; experienced rounds hand you a trace from curl or the browser's network panel and ask what went wrong. Strong answers name the exact header and the component that reads it.

By Published 9 min read

Where HTTP questions show up

Few companies run a round called "HTTP", yet the protocol sits under backend, web, mobile, SRE, QA automation and application security interviews. A backend loop may ask why an endpoint's responses are stale for some users. A frontend loop asks why a cookie is not sent on a cross-site request. An SRE loop shows a 502 from a load balancer and asks where to look. Security roles go further into header parsing and smuggling. API design itself, such as resource naming and which status code to pick, is covered in REST API interview questions; this page stays on the protocol underneath.

  1. Quick checksMethods, the parts of a message, header names you should recognize, and what a proxy is allowed to change.
  2. Explain a behaviorWhy a page loaded old CSS, why a download resumed, why a login cookie vanished after a redirect.
  3. Read a traceRaw request and response headers from curl -v or a HAR file, with one detail that explains the bug.
  4. Design follow-upsCache policy for a release, cookie policy for a single sign-on flow, limits at the edge, safe proxy configuration.

Fundamentals: messages, methods and headers

First-round HTTP questions
QuestionWhat it testsWhat a strong answer shows
What are the parts of an HTTP/1.1 request on the wire?Message anatomyA request line (method, target, version), header fields one per line, an empty line, then an optional body. Lines end with CRLF. A response swaps the request line for a status line with version, code and reason phrase.
Why is the Host header mandatory in HTTP/1.1?Virtual hostingMany sites share one IP address, so the server needs the name to pick the site. In HTTP/2 and HTTP/3 the same role is played by the :authority pseudo-header.
What does HEAD return?MethodsThe same headers a GET would return, with no body. Useful for checking size, type or freshness without downloading the content.
What is OPTIONS used for?MethodsAsking which methods or features a target supports. Browsers also send it as the CORS preflight before certain cross-origin requests.
What are the five status code classes?Status lines1xx informational, 2xx success, 3xx redirection, 4xx the client made a mistake, 5xx the server failed. Clients that see an unknown code treat it like the x00 code of its class.
What does Content-Type describe, and what does Accept do?RepresentationContent-Type labels the media type of the body being sent, often with a charset. Accept lists what the client is willing to receive, with optional q weights for preference.
What is the difference between end-to-end and hop-by-hop headers?IntermediariesEnd-to-end headers travel to the final recipient. Hop-by-hop headers, such as Connection, Keep-Alive and Transfer-Encoding, apply to one connection and a proxy must not forward them as-is.
Is HTTP stateless if sites keep you logged in?StateThe protocol is stateless: each request stands alone. Sessions are built on top with cookies or tokens that the client sends on every request.
What does a 304 response contain?RevalidationNo body. It tells the client its stored copy is still valid and may carry updated headers such as Cache-Control or ETag.
What does Accept-Encoding: gzip, br mean, and what comes back?CompressionThe client can decode gzip and Brotli. The server may compress and says which with Content-Encoding; it should also send Vary: Accept-Encoding so caches keep the variants apart.
Why do header names ignore case, and what about HTTP/2?SyntaxField names were always case-insensitive in HTTP/1.1. HTTP/2 and HTTP/3 require them in lowercase on the wire, so code must never depend on the casing it sees.
First-round HTTP questions. Scroll sideways on a small screen.

Framing, negotiation and partial content

  • How does a receiver know where a body ends? With Content-Length, by counting bytes. With Transfer-Encoding: chunked, by reading size-prefixed chunks until a zero-size chunk. Failing both, for a response only, by the server closing the connection.
  • When does a server use chunked encoding? When it starts sending before it knows the total size, such as streaming a generated report or a server-rendered page. HTTP/2 and HTTP/3 do not use chunked encoding; their own frames carry the data.
  • What is `Expect: 100-continue` for? A client with a large upload sends headers first and waits. The server answers 100 Continue to accept, or a final error such as 413 or 401, which saves sending megabytes that would be rejected.
  • How does a download manager resume a file? It sends Range: bytes=500000- and, ideally, If-Range with the ETag it saw. A server that supports ranges replies 206 Partial Content with a Content-Range header; if the file changed, it sends the whole thing with 200 instead.
  • What does `Accept-Ranges: bytes` advertise? That byte-range requests are supported for the resource. Video players rely on it to seek without downloading everything before the point they jump to.
  • What is content negotiation, and what are its costs? The server picks a representation from Accept, Accept-Language or Accept-Encoding. Each negotiated header must appear in Vary, and every new variant multiplies cache entries, so many sites prefer separate URLs for languages.
  • What does Content-Disposition do? attachment; filename="report.csv" asks the browser to save the body as a file rather than display it.
  • What is a 1xx response like 103 Early Hints? An interim response sent before the final one. 103 can carry Link headers so the browser starts fetching critical assets while the server is still building the page.
def decode_chunked(raw: bytes) -> bytes:
    """Decode an HTTP/1.1 chunked body. Trailer fields after the last chunk are ignored."""
    body, pos = b"", 0
    while True:
        line_end = raw.index(b"\r\n", pos)
        size = int(raw[pos:line_end].split(b";")[0], 16)  # hex size, extensions dropped
        pos = line_end + 2
        if size == 0:
            return body
        body += raw[pos:pos + size]
        pos += size
        if raw[pos:pos + 2] != b"\r\n":
            raise ValueError("chunk data not followed by CRLF")
        pos += 2

wire = b"7\r\nhello, \r\nd\r\nchunked world\r\n0\r\n\r\n"
print(decode_chunked(wire))  # b'hello, chunked world'


def is_fresh(max_age: int, age_header: int, seconds_held: int) -> bool:
    """Simplified RFC 9111 idea: current age = Age from upstream + time held in this cache."""
    return age_header + seconds_held < max_age

print(is_fresh(max_age=600, age_header=120, seconds_held=300))  # True
print(is_fresh(max_age=600, age_header=120, seconds_held=500))  # False
Decoding a chunked body by hand and a simplified freshness check. Run with Python 3; the comments show the printed output.

Interviewers who ask you to parse chunked framing want to hear the edge cases: sizes are hexadecimal, a chunk line can carry extensions after a semicolon, trailers may follow the last chunk, and a real parser must cap sizes so a hostile peer cannot ask it to buffer gigabytes.

Caching questions, from browser to CDN

Intermediate caching and revalidation
QuestionWhat it testsWhat a strong answer shows
no-cache versus no-store?Directivesno-cache allows storing but forces revalidation before every reuse. no-store forbids keeping a copy at all, which is what sensitive pages need.
max-age versus s-maxage, and what does private mean?Shared cachesmax-age sets freshness for every cache. s-maxage overrides it for shared caches such as a CDN. private keeps the response out of shared caches entirely, for per-user pages.
What does the Age header tell you?Freshness mathHow many seconds the response has already spent in caches upstream. A copy is fresh while its current age stays below its freshness lifetime.
What is heuristic freshness?DefaultsWith no explicit lifetime, a cache may guess one, often from how long ago Last-Modified was. That is why responses without Cache-Control can still be reused, sometimes surprisingly.
What does Vary do, and how can it hurt?VariantsIt lists request headers that change the response, so the cache stores one copy per combination. Vary: User-Agent or Vary: Cookie can split a cache into near-useless fragments.
How do stale-while-revalidate and stale-if-error help?AvailabilityThe first lets a cache serve a slightly stale copy while it refreshes in the background. The second lets it serve stale content when the origin is failing, buying time during an outage.
How do you cache static assets for a year and still ship updates?Release strategyPut a content hash in each file name, serve those with a long max-age and immutable, and keep the HTML that references them short-lived or revalidated.
Strong versus weak ETags?ValidatorsA strong ETag promises byte-for-byte identity. A weak one (W/ prefix) means semantically equivalent, such as the same content compressed differently, and cannot be used for range requests.
Intermediate caching and revalidation. Scroll sideways on a small screen.

Cookies, redirects and browser behavior

  • What do Secure and HttpOnly do? Secure sends the cookie only over HTTPS. HttpOnly hides it from JavaScript, which limits what a cross-site scripting bug can steal.
  • Explain SameSite Strict, Lax and None. Strict never sends the cookie on cross-site requests. Lax sends it on top-level navigations with safe methods, and Chromium-based browsers apply it when no SameSite is set. None sends it everywhere but must be paired with Secure.
  • What do Domain and Path control? Which hosts and paths receive the cookie. Omitting Domain makes it host-only; setting it to a parent domain shares it with every subdomain, including ones you may not control.
  • Session versus persistent cookies? A cookie without Expires or Max-Age is a session cookie, though browsers that restore sessions can keep it alive longer than users expect.
  • Why might a cookie disappear after a login redirect? Typical causes: the Set-Cookie came on a 302 to another domain, the Domain or Path did not match the next URL, SameSite blocked it on a cross-site hop, or Secure was set while testing over plain HTTP.
  • What does HSTS do? Strict-Transport-Security tells the browser to use HTTPS for the host for a set period, so a later typed http:// link never goes out unencrypted. The preload list extends that to the very first visit.

Senior and scenario questions

  • What is HTTP request smuggling? A front proxy and a back server disagree on where a request ends, usually because one trusts Content-Length and the other Transfer-Encoding. The attacker's leftover bytes become the start of someone else's request. Fixes: reject messages with both headers, normalize at the edge, and prefer HTTP/2 end to end.
  • How should a proxy pass on the client's address? Through Forwarded or X-Forwarded-For, appending rather than replacing. The application should trust only entries added by its own proxies, since clients can forge the rest.
  • Users in one region see an old page after a deploy. How do you investigate? Compare response headers from that region: Age, Cache-Control, the CDN's cache status header and the ETag. Then check whether the HTML was cached too long or whether a Vary header split the purge.
  • A file upload fails at the same size every time. Where do you look? Body size limits at each hop: the load balancer, the reverse proxy and the app server. A 413 status or a reset connection points to which layer refused it.
  • Why can keep-alive connections cause 502s behind a load balancer? If the backend closes idle connections sooner than the balancer expects, the balancer may send a request on a socket that is already closing. Keep the backend's idle timeout longer than the balancer's.
  • What limits would you set at the edge? Header size, number of headers, body size per route, request timeouts for slow clients and rate limits, each with a clear status code so clients can tell them apart.
  • How does HTTP/2 change performance advice from the HTTP/1.1 era? Domain sharding and sprite sheets were workarounds for few parallel requests; with multiplexing over one connection they mostly hurt. Server push turned out to be little used and major browsers have dropped it, with 103 Early Hints filling part of that role.
  • How do you debug a request with curl? curl -v for the full exchange, -I for headers only, -H to add a header, --compressed to request and decode compression, and --resolve to hit a specific server behind a DNS name.

Fictional example

Answering "Why do some users keep getting the old JavaScript?"
Interviewer
After a release, some users get errors because the new HTML loads with an old app.js. What happened, and how do you fix it?
Candidate
My first guess is that app.js has a fixed name and a long max-age, so browsers and the CDN keep reusing the old copy while the HTML is fresh. I would confirm with curl against the CDN: look at Cache-Control, Age and the cache status on app.js, and compare its ETag with the new build. The short-term fix is a purge of that path. The lasting fix is to put a content hash in every asset name, serve those for a year with immutable, and give the HTML either no-cache or a short max-age so it always points at the current hashes. Then the old and new files can live side by side and no user gets a mixed release.

HTTP practice plan

  • Day 1: run curl -v against five sites you use and name every request and response header you see, including the ones you have never set yourself.
  • Day 2: in the browser's network panel, reload a page normally and with the cache disabled. Note which responses come from memory, disk, a 304 or the network, and why.
  • Day 3: write the chunked decoder above from memory, then add a size limit and trailer handling.
  • Day 4: draw the path of one request through a CDN, a load balancer and an app server, marking where each timeout, size limit and cache decision happens.
  • Day 5: set cookies with each SameSite value on a local page and test which cross-site requests carry them. Explain the result in under a minute.

HTTP rarely stands alone in a loop. Pair this page with computer networks interview questions for TCP, TLS and the version history, HTML5 interview questions for the browser APIs that sit on top of these requests, and backend developer interview questions for the wider server round.

Protocol answers fall apart when you skip the order of evidence, so record yourself talking through a trace. Natively, an AI interview assistant for Mac and Windows, transcribes that mock round on your computer so you can check whether you named the header before guessing at the cause. In practice it can read a pasted response dump or a network-panel screenshot and point at the line worth discussing, and with Pro or the free trial it can draw on the résumé and job description you add. Your transcript and notes stay available for review afterward.

Questions people ask

What HTTP questions are asked in interviews?

The parts of a request and response, Host and other core headers, how a body's length is known, chunked transfer, range requests, Cache-Control directives, ETags and 304s, cookie attributes, proxies and how to read a curl trace.

What is the difference between no-cache and no-store?

no-cache lets a cache keep the response but makes it revalidate with the server before each reuse. no-store tells every cache not to keep a copy at all.

How do I prepare for HTTP questions as a backend developer?

Read raw traces with curl -v until every header is familiar, practice explaining caching and cookie bugs from the headers alone, and know where timeouts and size limits sit between the client and your app.

Is HTTP the same as REST?

No. HTTP is the protocol that carries requests and responses. REST is an architectural style for designing APIs, and most REST APIs happen to use HTTP methods, status codes and headers.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP