Interview Q&A / Computer Networks

INTERVIEW Q&A · 55 QUESTIONS

Computer Networks interview questions

What happens when you open a website, TCP vs UDP, DNS and HTTP.

  1. What are the common HTTP methods and status codes, and what does idempotent mean?

    GET reads, POST creates or triggers an action, PUT replaces, PATCH partly updates and DELETE removes. A method is idempotent if repeating the same request leaves the server in the same state as doing it once - GET, PUT and DELETE are, POST is not. Status codes are grouped as 2xx success, 3xx redirect, 4xx client error and 5xx server error.

    BeginnerIn-depth5 min read
  2. What happens when you type a URL in the browser and press Enter?

    The browser finds the server's IP address with DNS, opens a TCP connection, sets up TLS for HTTPS, sends an HTTP request, gets a response and then parses and renders the HTML, CSS and JavaScript into the page you see.

    BeginnerIn-depth3 min read
  3. What is the difference between HTTP and HTTPS, and what does TLS actually do?

    HTTPS is HTTP sent inside a TLS connection. TLS gives three things plain HTTP lacks - encryption so others on the network cannot read the data, integrity so it cannot be changed in transit, and authentication through a certificate so you know you are talking to the real site.

    BeginnerIn-depth4 min read
  4. What is HTTP keep-alive, and why does it speed up page loads?

    Keep-alive reuses one TCP connection for several HTTP requests instead of opening a new one each time. This saves the handshake round trips (and the TLS handshake for HTTPS) for every file after the first. It is the default in HTTP/1.1.

    BeginnerQuick answer1 min read
  5. Why does an HTTP/1.1 request need a Host header?

    One server IP can host many websites. The TCP connection only carries the IP address, so the Host header tells the server which site the browser wants, letting it choose the right content. HTTP/1.1 requires it.

    BeginnerQuick answer1 min read
  6. How do Cache-Control and ETag let a browser reuse a response?

    Cache-Control: max-age tells the browser how long it may reuse a response without asking. After that, the browser can revalidate with If-None-Match and the ETag; if nothing changed, the server replies 304 Not Modified with no body.

    IntermediateQuick answer1 min read
  7. What are the main differences between HTTP/1.1 and HTTP/2?

    HTTP/2 uses a binary format, multiplexes many requests over a single TCP connection, compresses headers with HPACK and allows prioritisation. HTTP/1.1 is plain text and handles one request at a time per connection, so browsers open several connections instead.

    IntermediateQuick answer1 min read
  8. What is head-of-line blocking, and how do HTTP/2 and HTTP/3 deal with it?

    Head-of-line blocking is when one slow or lost item holds up everything queued behind it. HTTP/1.1 blocks at the request level, HTTP/2 fixes that with multiplexing but still blocks at the TCP level on packet loss, and HTTP/3 over QUIC removes even that.

    AdvancedQuick answer1 min read