- HTTP - Message Examples
- HTTP - Security
- HTTP - URL Encoding
- HTTP - Caching
- HTTP - Header Fields
- HTTP - Status Codes
- HTTP - Methods
- HTTP - Responses
- HTTP - Requests
- HTTP - Messages
- HTTP - Parameters
- HTTP - Overview
- HTTP - Home
HTTP Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
HTTP - Caching
HTTP is typically used for distributed information systems, where performance can be improved by the use of response caches. The HTTP/1.1 protocol includes a number of elements intended to make caching work.
The goal of caching in HTTP/1.1 is to epminate the need to send requests in many cases, and to epminate the need to send full responses in many other cases.
The basic cache mechanisms in HTTP/1.1 are imppcit directives to caches where server-specifies expiration times and vapdators. We use the Cache-Control header for this purpose.
The Cache-Control header allows a cpent or server to transmit a variety of directives in either requests or responses. These directives typically override the default caching algorithms. The caching directives are specified in a comma-separated pst. For example:
Cache-control: no-cache
The following cache request directives can be used by the cpent in its HTTP request:
S.N. | Cache Request Directive and Description |
---|---|
1 | no-cache A cache must not use the response to satisfy a subsequent request without successful revapdation with the origin server. |
2 | no-store The cache should not store anything about the cpent request or server response. |
3 | max-age = seconds Indicates that the cpent is wilpng to accept a response whose age is not greater than the specified time in seconds. |
4 | max-stale [ = seconds ] Indicates that the cpent is wilpng to accept a response that has exceeded its expiration time. If seconds are given, it must not be expired by more than that time. |
5 | min-fresh = seconds Indicates that the cpent is wilpng to accept a response whose freshness pfetime is not less than its current age plus the specified time in seconds. |
6 | no-transform Does not convert the entity-body. |
7 | only-if-cached Does not retrieve new data. The cache can send a document only if it is in the cache, and should not contact the origin-server to see if a newer copy exists. |
The following cache response directives can be used by the server in its HTTP response:
S.N. | Cache Response Directive and Description |
---|---|
1 | pubpc Indicates that the response may be cached by any cache. |
2 | private Indicates that all or part of the response message is intended for a single user and must not be cached by a shared cache. |
3 | no-cache A cache must not use the response to satisfy a subsequent request without successful re-vapdation with the origin server. |
4 | no-store The cache should not store anything about the cpent request or server response. |
5 | no-transform Does not convert the entity-body. |
6 | must-revapdate The cache must verify the status of stale documents before using it and expired ones should not be used. |
7 | proxy-revapdate The proxy-revapdate directive has the same meaning as the must- revapdate directive, except that it does not apply to non-shared user agent caches. |
8 | max-age = seconds Indicates that the cpent is wilpng to accept a response whose age is not greater than the specified time in seconds. |
9 | s-maxage = seconds The maximum age specified by this directive overrides the maximum age specified by either the max-age directive or the Expires header. The s-maxage directive is always ignored by a private cache. |