HTTP headers | cache-control Last Updated : 16 Jun, 2020 Comments Improve Suggest changes Like Article Like Report The Cache-Control header is a general header, that specifies the caching policies of server responses as well as client requests. Basically, it gives information about the manner in which a particular resource is cached, location of the cached resource, and its maximum age attained before getting expired i.e. time to live. Syntax: Cache-Control: <directive> [, <directive>]* Directives: This header accept 15 directive all of the described below: Public: This directive indicates that the response can be stored by any cache without any restriction. In case the response is non-cacheable, it can still be cached. Private:It indicates that only browser cache is eligible to store the response. no-cache: It indicates that the response can be stored by any cache without any restriction even if it is non-cacheable. The condition that needs to be satisfied here is that the stored response must be validated by the origin server before being used. no-store: It indicates that the response cannot be stored by any cache. max-age=<seconds>: It indicates the maximum amount of time a resource remains fresh and can be requested to be accessed. s-maxage=<seconds>: This directive is mainly used for shared cache by content delivery networks(CDNs). It overrides the max-age directive and expires header when present. max-stale[=<seconds>]: It indicates that only a stale response is accepted by the client. The optional time in seconds indicate the maximum limit of staleness which will be accepted by the client. min-fresh=<seconds>: It indicates that only the response which is fresh is accepted by the client for the specified duration of time specified in seconds. stale-while-revalidate=<seconds>: It indicates that the stale response will be accepted by the client along with asynchronously looking for fresh responses. The time in seconds represents the duration for which the client will accept stale response stale-if-error=<seconds>: It indicates that the stale response will be accepted by the client if the check for fresh one fails. The time in seconds represents the duration for which the client will accept a stale response after initial expiration. must-revalidate: It indicates caches cannot use their stale resources after they have become stale without getting it validated from the origin server. proxy-revalidate: This directive is similar to must-revalidate. However, it only works for shared caches and is ignored by the private caches. Immutable: It indicates that the response body remains unchanged over the period of time. no-transform: It indicates that the resources cannot be transformed or modified into another form. only-if-cached: It indicates that the network cannot be used for the response by the client. It means that the cache can use either stored response or 504 status code. Examples: For Preventing cache, following response header can be used: Cache-Control: no-store For the purpose of caching static assets, the following response header can be used: Cache-Control: public, max-age=604800, immutable For Requiring revalidation, the following can be used: Cache-Control: no-cache Cache-Control: no-cache, max-age=0 Cache-Control: no-cache, max-age=0, stale-while-revalidate=300 Supported Browsers: The browsers are compatible with HTTP Cache-Control header are listed below: Google Chrome Edge Firefox Internet Explorer Opera Safari Comment More infoAdvertise with us Next Article HTTP headers | cache-control M manandeep1610 Follow Improve Article Tags : Computer Networks HTTP-headers Similar Reads HTTP headers | Access-Control-Max-Age The Access-Control-Max-Age HTTP header is a response header that gives the time for which results of a CORS preflight request that checks to see if the CORS protocol is understood and a server is aware using specific methods and headers, can be cached. The CORS preflight request contained in the Acc 1 min read HTTP headers | Age The HTTP header Age defines the times in seconds of the object that have been in the proxy cache. Usually, the age header is close to zero. It is just summoned from the server, used to calculate the proxies' current date and the date. It is a response header. Syntax: age: <delta-seconds> Direc 1 min read HTTP headers | Access-Control-Request-Method The HTTP headers Access-Control-Request-Method is a request type header which has been used to inform the server that which HTTP method will be used when the actual request is made. Syntax: Access-Control-Request-Method: <method> Directives: This header accept a single directive which is menti 1 min read HTTP headers | X-DNS-Prefetch-Control The X-DNS-Prefetch-Control is an HTTP response type header that informs the browser whether DNS prefetch to be executed or not. Turning it on may not work as many browsers may not support it in all the situations. Turning it off should disable in all supported browsers. Most of the browsers will ign 2 min read HTTP headers | expires The HTTP Expires header is a response-type header, the fundamental way of controlling the caches present. The expire header contains the date and time which denotes the period where the object can stay alive. Once the period expires, the object becomes stale. Almost every client support expire heade 2 min read Like