php etag

PHP에서 ETag처리방법

.htaccess 파일을 생성하고 아래 라인을 추가한다. FileETag MTime Size 그리고나서 ETag를 사용할 페이지에 아래 PHP코드를 넣는다. <?php $file = 'example.php'; $last_modified_time = filemtime($file); $etag = md5_file($file); header("Last-Modified: ".gmdate("D, d M Y H:i:s", $last_modified_time)." GMT"); header("Etag: $etag"); if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time || trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) { header("HTTP/1.1 304 Not Modified"); exit; } ?>

Scroll to top