HTTP Basics3
HTTP Basics3
headers
HTTP headers let the client and the server pass
additional information with a message in a request or
response.
Headers can be grouped according to
their contexts
Request headers
Contain more information about the resource to be fetched, or about the
client requesting the resource.
Response headers
Hold additional information about the response, like its location or
about the server providing it.
Representation headers
Contain information about the body of the resource, like its MIME type,
or encoding/compression applied.
Payload headers
Contain representation-independent information about payload data,
including content length and the encoding used for transport.
End-to-end headers
These headers must be transmitted to the final recipient of the message:
the server for a request, or the client for a response. Intermediate
proxies must retransmit these headers unmodified and caches must
store them.
Hop-by-hop headers
These headers are meaningful only for a single transport-level
connection, and must not be retransmitted by proxies or cached. Note
that only hop-by-hop headers may be set using the Connection
header.
Content-Type
Cache-
Control
Security
Session
Content-
Type
The HTTP Content-Type representation header is used to indicate
the original media type of a resource before any content encoding is
applied.
const
videoPlayer=document.getElementById...
Cache-
Control
The HTTP Cache-Control header holds directives (instructions)
in both requests and responses that control caching in browsers
and shared caches (e.g., Proxies)
(HTTP) cache
Implementation that holds requests and responses for reusing
in subsequent requests. It can be either a shared cache or a
private cache.
Shared cache
Cache that exists between the origin server and clients (e.g.
Proxy, CDN). It stores a single response and reuses it with
multiple users — so developers should avoid storing
Private cache
Cache that exists in the client. It is also called local
cache or browser cache. It can store and reuse
personalized content for a single user.
Store response
Store a response in caches when the response is
cacheable. However, the cached response is not always
reused as-is. (Usually, "cache" means storing a
response.)
Reuse response
Reuse cached responses for subsequent requests.
Age
Revalidate response
Ask the origin server whether or not the stored
response is still fresh. Usually, the revalidation is done
through a conditional request.
Fresh response
Indicates that the response is fresh. This usually means
the response can be reused for subsequent requests,
depending on request directives.
Stale response
Indicates that the response is a stale response. This
usually means the response can't be reused as-is.
Cache storage isn't required to remove stale responses
immediately because revalidation could change the
HTTP security
headers
HTTP security headers are those HTTP headers that are
related specifically to security, exchanged between a
client (like a web browser) and a server to define the
security of HTTP communication
The most important HTTP
security headers
Strict-Transport- Permissions-
Security Policy
Content-Security- X-Frame-
Policy Options
X-Content-Type- X-XSS-
HTTP
session
In client-server protocols, like HTTP, sessions consist of
three phases:
The client sends its request, and waits for the answer.