0% found this document useful (0 votes)
26 views3 pages

HTTP Interview QA

Uploaded by

fred2dash7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

HTTP Interview QA

Uploaded by

fred2dash7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

HTTP Interview Questions & Answers

1. What is HTTP?
HTTP (HyperText Transfer Protocol) is an application layer protocol used for transmitting
hypermedia documents, such as HTML, over the web. It defines how requests and responses are
structured between clients (browsers) and servers.

2. Difference between HTTP and HTTPS?


HTTPS is HTTP over TLS/SSL. It ensures encryption, authentication, and data integrity, making
communication secure compared to plain HTTP.

3. What are the main features of HTTP?


HTTP is stateless, connectionless, extensible, and supports caching, persistent connections, and
content negotiation.

4. How does HTTP maintain state if it is stateless?


Through mechanisms like cookies, sessions, and tokens, which allow client–server interactions to
persist across multiple requests.

5. What techniques are used to improve HTTP performance?


Caching, persistent connections, cookies and sessions, header compression, multiplexing (in
HTTP/2+), and use of CDNs.

6. Explain request and response in HTTP.


A client sends a request (method, URL, headers, optional body). The server replies with a response
(status code, headers, optional body).

7. What are HTTP status codes?


They indicate the result of a request: 1xx (informational), 2xx (success), 3xx (redirection), 4xx
(client errors), 5xx (server errors).

8. Difference between PUT and POST?


POST creates new resources, not necessarily idempotent. PUT updates or replaces a resource and
is idempotent.

9. Difference between GET and POST?


GET retrieves data and is safe/idempotent. POST sends data to create or modify resources and is
not idempotent.

10. What are HTTP headers?


Metadata in request/response messages used to pass information such as content type, caching
rules, or authentication details.
11. Explain content negotiation in HTTP.
The process where a client specifies preferred formats (e.g., JSON, XML) using headers like
Accept, and the server responds accordingly.

12. What is an Idempotent method?


A method that produces the same result no matter how many times it is repeated (e.g., GET, PUT,
DELETE).

13. What are conditional requests?


Requests that use headers like If-Modified-Since or ETag to fetch data only if it has changed,
reducing bandwidth usage.

14. What are persistent connections?


A feature where a single TCP connection is reused for multiple requests/responses, reducing
overhead.

15. Difference between HTTP/1.0 and HTTP/1.1?


HTTP/1.0 opened a new connection for each request. HTTP/1.1 introduced persistent connections,
pipelining, chunked transfers, and better caching.

16. What is HSTS?


HTTP Strict Transport Security forces browsers to use HTTPS for a domain, enhancing protection
against downgrade and MITM attacks.

17. Difference between Basic Authentication and Bearer Token?


Basic Auth sends base64-encoded credentials with each request. Bearer Token uses a token (e.g.,
JWT) that represents user authentication.

18. What is CORS?


Cross-Origin Resource Sharing is a mechanism that allows controlled access to resources from a
different origin by using headers like Access-Control-Allow-Origin.

19. Difference between stateful and stateless protocol?


HTTP is stateless (server doesn’t store session info). Stateful protocols, like FTP, maintain session
state between client and server.

20. What are safe methods in HTTP?


Safe methods (GET, HEAD, OPTIONS, TRACE) do not alter server state. They are intended for
read-only operations.

21. Why is GET safe and idempotent?


Because it only retrieves data without modifying resources, and multiple identical GET requests
return the same result.
22. Why is POST not safe or idempotent?
POST creates/modifies resources, changing server state. Repeating the same POST may create
duplicates or additional changes.

23. Compare HTTP/1.1, HTTP/2, and HTTP/3.


HTTP/1.1 uses one request per connection (with optional pipelining). HTTP/2 uses multiplexing,
header compression, and binary framing. HTTP/3 uses QUIC over UDP, eliminating head-of-line
blocking.

24. What is pipelining vs multiplexing?


Pipelining sends multiple requests sequentially without waiting for responses. Multiplexing allows
multiple requests/responses in parallel over one connection.

25. How does HTTPS secure communication?


By using TLS to provide encryption, authentication, and integrity, preventing eavesdropping and
tampering.

26. How to optimize HTTP performance?


Use caching, CDNs, compression, connection reuse, multiplexing, and minimal headers.

27. What is Set-Cookie used for?


A server header that tells the client to store a cookie for future requests.

28. Difference between cookies and sessions?


Cookies store data on the client side. Sessions store data on the server side, with a cookie
containing the session ID.

29. What is HTTP/2 header compression?


HTTP/2 uses HPACK compression to reduce header size and improve performance.

30. What is Head-of-Line (HOL) blocking?


A performance issue where a single delayed packet blocks others behind it, common in HTTP/1.1
pipelining.

31. Why is QUIC faster?


QUIC (used in HTTP/3) is built on UDP, allowing multiplexing without HOL blocking and faster
connection establishment.

You might also like