Caching in HTTP
HTTP is used for distributed operating systems, where using the response caches, we can improve the performance. The HTTP/1.1 protocol includes a number of elements which is intended to make properly working of caching. Because these elements interact with each other and they are inextricable from other aspects of the protocol, it is useful to describe the HTTP caching design separately from the detailed description of response codes, methods, headers, etc.
The HTTP Caching is basically used to eliminate the need to send the request in many cases. It is also used to eliminate the need to send full responses in many other cases.
In HTTP, cache mechanisms are implicit directives to caches where expiration times and validators are specified by the server. For this purpose, we use the Cache-Control header.
The Cache-Control header is used to allow the client or the server to transmit a variety of directive in either request or response. The default caching algorithm is overridden by these directives. The directives of the caching are specified in a comma-separated list.
Example
The client is using the cache request directives in its HTTP request as follows:
S.N. |
Directive of Cache
Request and Description |
1 |
no-cache |
2 |
no-store |
3 |
max-age = seconds |
4 |
max-state [=seconds ] |
5 |
min-fresh= seconds |
6 |
no-transform |
7 |
only-if-cached |
The directives of
cache response can be used by the server in its HTTP response as follows:
S.N. |
Directive of Cache
Response and Description |
1 |
public |
2 |
private |
3 |
no-cache |
4 |
no-store |
5 |
no-transform |
6 |
must-revalidate |
7 |
proxy-revalidate |
8 |
max-age = seconds |
9 |
s-maxage = seconds |
0 Comments