Cache saves bandwidth by loading images and content from the visitor's computer instead of the web server. // Cache forever header('Cache-Control: public'); header('Expires: Sun, 17 Jan 2038 19:14:07 GMT'); // maximum value supported by the 32 bit Unix time/date format // Cache for 1 hour (3600 seconds) header('Cache-Control: max-age=3600, must-revalidate'); // Disable cache header("Cache-Control: no-cache, must-revalidate"); header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); Useful Cache-Control response headersmax-age=[seconds] — specifies the maximum amount of time that an representation will be considered fresh. Similar to Expires, this directive is relative to the time of the request, rather than absolute. [seconds] is the number of seconds from the time of the request you wish the representation to be fresh for.s-maxage=[seconds] — similar to max-age, except that it only applies to shared (e.g., proxy) caches. public — marks authenticated responses as cacheable; normally, if HTTP authentication is required, responses are automatically uncacheable (for shared caches). 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. no-store — instructs caches not to keep a copy of the representation under any conditions. must-revalidate — 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. For more info, see http://www.mnot.net/cache_docs/ |
Web Development >