HTTP Cache control is used for improved performance of distributed information systems.The HTTP/1.1 protocol introduced a new element of headers, Cache-Control response headers.These element interact with each other.The main goal of caching to eliminate unnecessary round trip of request as well as to eliminate the need to send full responses in many other cases.
Useful Cache-Control response headers include:
• max-age=[seconds] — This is specifies the maximum amount of time of the request you wish the representation to be fresh.Its similar to expires.
• s-maxage=[seconds] — Its similar to max-age except it only applies to shared (e.g., proxy) caches.
• public — Its used for to marks authenticated responses as cacheable or not, if HTTP authentication is required, responses are automatically uncacheable.
• no-cache — forces caches to submit the request to the origin server for validation before releasing a cached copy, every time. This is useful to assure that authentication is respected (in combination with public), or to maintain rigid freshness, without sacrificing all of the benefits of caching.
Note:Most HTTP/1.0 caches does not recognize or obey this directive.
• no-store — instructs caches not to keep a copy of the representation under any conditions.
• must-revalidate — This property tells caches that they must obey any freshness information you give them about a representation. HTTP allows caches to serve stale representations under special conditions; by specifying this header, you’re telling the cache that you want it to strictly follow your rules.
• proxy-revalidate — similar to must-revalidate, except that it only applies to proxy caches.
header(“Cache-Control: max-age=3600, must-revalidate”);