add(new DateInterval(expires)); } if ($expires instanceof DateTime) { $expires = $expires->format(DateTime::RFC2822); } header('Expires: '.expires); } static public function setETagHeader($etag) { if (empty($etag)) { return; } self::enableCaching(); if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) { self::setStatus(self::STATUS_NOT_MODIFIED); exit; } header('ETag: '.$etag); } static public function setLastModifiedHeader($lastModified) { if (empty($lastModified)) { return; } if ($lastModified instanceof DateTime) { $lastModified = $lastModified->format(DateTime::RFC2822); } self::enableCaching(); if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && trim($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified) { self::setStatus(self::STATUS_NOT_MODIFIED); exit; } header('Last-Modified: '.$lastModified); } }