private function cache_headers($file) {
$last_mod = filemtime($this->request->server['SCRIPT_FILENAME']);
$gmt_mtime = gmdate("D, d M Y H:i:s T", $last_mod);
$this->response->addHeader('ETag: "'.md5($last_mod . $file) . '"');
$this->response->addHeader('Last-Modified: ' . $gmt_mtime);
$this->response->addHeader('Cache-Control: must-revalidate, proxy-revalidate, max-age=3600');
if(isset($this->request->server['HTTP_IF_MODIFIED_SINCE']) || isset($this->request->server['HTTP_IF_NONE_MATCH'])) {
if ($this->request->server['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime || str_replace('"', '', stripslashes($this->request->server['HTTP_IF_NONE_MATCH'])) == md5($last_mod . $file)) {
$this->response->addHeader('HTTP/1.1 304 Not Modified');
$this->response->addHeader("Vary: Accept-Encoding,User-Agent");
exit();
}
}
}
private function cache_headers($file) {
$last_mod = filemtime($this->request->server['SCRIPT_FILENAME']);
$gmt_mtime = gmdate("D, d M Y H:i:s T", $last_mod);
$this->response->addHeader('ETag: "'.md5($last_mod . $file) . '"');
$this->response->addHeader('Last-Modified: ' . $gmt_mtime);
$this->response->addHeader('Cache-Control: must-revalidate, proxy-revalidate, max-age=3600');
if(isset($this->request->server['HTTP_IF_MODIFIED_SINCE']) || isset($this->request->server['HTTP_IF_NONE_MATCH'])) {
if ($this->request->server['HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime || str_replace('"', '', stripslashes($this->request->server['HTTP_IF_NONE_MATCH'])) == md5($last_mod . $file)) {
$this->response->addHeader('HTTP/1.1 304 Not Modified');
$this->response->addHeader("Vary: Accept-Encoding,User-Agent");
exit();
}
}
}
$IfModifiedSince = false;
$env = $this->request->clean($_ENV);
if (isset($env['HTTP_IF_MODIFIED_SINCE'])) {
$IfModifiedSince = strtotime(substr($env['HTTP_IF_MODIFIED_SINCE'], 5));
}
if (isset($this->request->server['HTTP_IF_MODIFIED_SINCE'])) {
$IfModifiedSince = strtotime(substr($this->request->server['HTTP_IF_MODIFIED_SINCE'], 5));
}
<?php
$timestamp = strtotime($date_modified);
$LastModified_unix = $timestamp; // время последнего изменения страницы
$LastModified = gmdate("D, d M Y H:i:s \G\M\T", $LastModified_unix);
$IfModifiedSince = false;
if (isset($_ENV['HTTP_IF_MODIFIED_SINCE']))
$IfModifiedSince = strtotime(substr($_ENV['HTTP_IF_MODIFIED_SINCE'], 5));
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
$IfModifiedSince = strtotime(substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 5));
if ($IfModifiedSince && $IfModifiedSince >= $LastModified_unix) {
header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
exit;
}
header('Last-Modified: '. $LastModified);
?>
<?php
$timestamp = strtotime($date_modified);
$LastModified_unix = $timestamp; // время последнего изменения страницы
$LastModified = gmdate("D, d M Y H:i:s \G\M\T", $LastModified_unix);
$IfModifiedSince = false;
if (isset($_ENV['HTTP_IF_MODIFIED_SINCE']))
$IfModifiedSince = strtotime(substr($_ENV['HTTP_IF_MODIFIED_SINCE'], 5));
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
$IfModifiedSince = strtotime(substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 5));
if ($IfModifiedSince && $IfModifiedSince >= $LastModified_unix) {
header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
exit;
}
header('Last-Modified: '. $LastModified);
?>