Created
November 3, 2017 18:03
-
-
Save Igor-Lopes/57b1e0dd953482ceae19e4072fc54b60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file = 'myfile.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; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
function set_cache($content) {
$etag = md5(serialize($content));
}