mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-10 22:32:13 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 03f90a160b | |||
| 1d8e7c2caf |
@@ -42,12 +42,24 @@ class Response {
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cache($duration = 2592000) {
|
public function cache($eTag, $lastModified = 2592000) {
|
||||||
|
|
||||||
$this->headers([
|
$this->headers([
|
||||||
'Cache-Control: public,max-age='.$duration.',must-revalidate',
|
'Cache-Control: public',
|
||||||
'Expires: '.gmdate('D, d M Y H:i:s',(time()+$duration)).' GMT',
|
'Last-Modified: ' . gmdate("D, d M Y H:i:s", $lastModified) . ' GMT',
|
||||||
'Last-modified: '.gmdate('D, d M Y H:i:s',time()).' GMT'
|
'Etag: ' . $eTag
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) === $lastModified ||
|
||||||
|
isset($_SERVER['HTTP_IF_NONE_MATCH']) && $_SERVER['HTTP_IF_NONE_MATCH'] === $eTag) {
|
||||||
|
|
||||||
|
$this->headers([
|
||||||
|
'HTTP/1.1 304 Not Modified'
|
||||||
|
]);
|
||||||
|
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user