Caching in HTTP

HTTP is typically used for distributed information systems, where performance can be enhanced by using cached feedback. The HTTP / 1.1 protocol includes several elements that are intended to perform caching tasks.

HTTP is typically used for distributed information systems, where performance can be enhanced by using cached feedback. The HTTP / 1.1 protocol includes several elements that are intended to perform caching tasks.

The goal of saving to hidden memory in HTTP / 1.1 is to calculate the need to send requests in many cases, and to calculate the need to send full responses in many other cases.

The basic caching technique in HTTP / 1.1 is to include instructions to cache memory where the Server determines the time and expiration date. We use the Cache-Control field for this purpose.

The Cache-Control field allows a Client or Server to transmit various directives in either requests or responses. These directives are characterized by having higher priority than caching algorithms by default. Indicators stored in hidden memory are defined in a list separated by commas. For example:

 Cache-control: no-cache 

The following are directives for caching requests that can be used by the Client in its HTTP request:

Instructions for hidden memory description No-cache description

A hidden memory must not use the response to satisfy a subsequent request without re-confirming success with the original Server.

no-store

The cache should not store anything about the Client request or the Server counter.

max-age = (in seconds)

Indicates that the Client wants to accept a response whose time is not greater than the time specified in seconds (s).

max-stale [= seconds]

Indicates that the Client is willing to accept a response that has exceeded the expiration time. If the number of seconds is provided, it must not be expired by more than that time.

min-fresh = seconds

Indicates that the Client is willing to accept a response whose health life is no less than its current age plus the specified time in seconds.

no-transform

Do not convert the body of the object.

only-if-cached

Do not get new data. Hidden memory can send a document only if it is in hidden memory, and should not contact the original Server to consider if a newer copy exists.

The following caching response directives can be used by the Server in its HTTP response:

Hide memory feedback instructions Public description

Indicates that feedback can be kept in memory hidden by any hidden memory.

private

Indicates that all or part of the response message is considered as for a single user and must not be kept in hidden memory by a shared cache.

no-cache

A hidden memory must not use feedback to satisfy a subsequent request without re-confirming success with the original Server.

no-store

Caching should not save anything about Client requests or Server responses.

no-transform

Do not convert the body of the object.

must-revalidate

The cache must verify the status of old documents before using it and expired documents should not be used.

proxy-revalidate

The instruction to re-authorize authorization has the same meaning as the must-revalidate directive, except it does not apply to hidden user agent memory that is not shared.

max-age = seconds

Indicates that the client is willing to accept a request whose age is not greater than the specified time in seconds.

s-maxage = seconds

The maximum age defined by this directive exceeds the maximum age specified by either the max-age directive or Expires Header. The s-maxage instruction is always ignored by an individual memory.

According to Tutorialspoint

Previous article: Header fields in HTTP

Next lesson: URL encoding in HTTP

3.5 ★ | 2 Vote