N9. HTTP Flashcards
What does HTTP stand for?
Hyper Text Transfer Protocol
What is HTTP?
- protocol for www
- client-server protocol
- application level protocol (runs over TCP)
- session: stateless (single req, single resp)
- text-based (printable strings for headers and content of messages)
(focus on HTTP/1.1)
In an HTTP response header, what would A and B refer to for content-type: A/B
A is the type of media e.g. text
B is the actual content type of the payload e.g. HTML
Type A/subtype B
e.g. text/html
What are the three common HTTP methods?
GET
- request specific page/object
- request has header only, no message body
HEAD
- request only header, not object itself
- can check timestamp against local cache
- request has header only, no message body
POST
- send form data to server
- request body contains form data
What are the HTTP response code types? Give some examples
Types: 1xx Informational 2xx Successful 3xx Redirection 4xx Client error 5xx Server error
Examples: 200 OK 301 Moved permanently 404 Not found 502 Bad Gateway
What does it mean for HTTP to be stateless?
- client requests treated independently
- server does not maintain state/history of previous client requests
(notion of application-level session must be built into the app. using HTTP) - client must fetch all page contents by sending separate GET requests for components of the page
What is the main difference between HTTP 1.0 and HTTP 1.1 when fetching a page.
(A TCP connection must first be established)
HTTP 1.0 - closes TCP connection and creates a new one for every object linked on page
[Connection: close]
HTTP 1.1 - TCP connection kept open to fetch multiple objects
(reduced overhead)
[Connection: keep-alive]
Properties of HTTP/2
- normal HTTP sitting over TLS
- multiplexing: one TCP connection for multiple requests
- piping: client can send requests in parallel and they are dealt with on one connection
- uses binary encoding for compression instead of text-based protocol
- server PUSH: server pre-emptively sends objects to client (caching)
Properties of HTTP/3
- still being developed
- will run over QUIC (UDP) not TCP
- built-in security
- faster connection set-up
- features of HTTP/2
What is the cache?
- performance optimisation tool
- localised copy of data
- means data is ‘closer’ to where it needs to be (spatial locality)
- copied to cache ahead of time (temporal locality)
- if original version of data changes, cached data will not (stale) because it is a copy
What is a proxy?
Something (system or router) that takes the place of the client to communicate with the server
- for caching, the proxy can have a shared cache, allowing multiple clients to access cached resources from one place
- could be used for security/privacy to monitor what all clients accessing a site are viewing
For caching, state some example header fields from requester and responder
Requester - max-age - min-fresh - max-stale Responder - must-revalidate - no-cache - no-store etc.