PHP 캐시 헤더

1 개요[ | ]

PHP 캐시 헤더, PHP Cache Header
  • 브라우저에서의 캐시 주기를 설정할 수 있다.
  • POST 메소드에서는 캐시가 되지 않는다.
// 1년간 캐시 설정하기
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + (60*60*24*365)) . ' GMT'); // 유효기한
header("Cache-Control: max-age=".(60*60*24*365)); // 캐시 최대 길이 (초 단위)
header("Pragma: public");

// 캐시 설정하지 않기
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // 과거 아무 때나 잡으면 됨.
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}