====== Cache Control ======
phpでクライアント(ブラウザ)、プロキシのキャッシュを制御する方法を紹介する。
===== nocache control =====
クライアント、プロキシにキャッシュを無効化するためのコードを次に示す。
header('Pragma: no-cache');
header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
header('Last-Modified:');
===== private cache control =====
共有されないキャッシュを指定する場合のコードを次に示す。
$cache_expire = session_cache_expire() * 60;
header('Pragma: no-cache'); // anti-proxy
header('Expires:'); // anti-mozilla
header("Cache-Control: private, max-age={$cache_expire}, pre-check={$cache_expire}"); // HTTP/1.1 client
header('Last-Modified:');
===== reference =====
- [[http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9|HTTP/1.1: Header Field Definitions #14.9 Cache Control]]