Пример #1
0
 /**
  * Less constructor.
  * @param $file
  * @param $cache
  */
 public function __construct($file, $cache)
 {
     Utilities::setHeader('Content-Type', 'text/css');
     $this->file = $file;
     $this->cache = $cache;
     return $this;
 }
Пример #2
0
 /**
  * Js constructor.
  * @param $file
  * @param $cache
  */
 public function __construct($file, $cache)
 {
     Utilities::setHeader('Content-Type', 'application/javascript');
     $this->file = $file;
     return $this;
 }
Пример #3
0
 /**
  * @return $this
  */
 public function setHeaders()
 {
     $lastModifiedDate = $this->last_modified;
     $eTag = hash('sha256', $lastModifiedDate . $this->file_data['hash']);
     $checkModifiedSince = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false;
     $checkETag = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] : false;
     if ($checkModifiedSince && strtotime($checkModifiedSince) == $lastModifiedDate || $checkETag == $eTag) {
         Utilities::statusCode(304, 'Not Modified');
         $this->modified = true;
     } else {
         $maxage = 60 * 60 * 24 * 320;
         // Avoid the hard limit some servers have
         Utilities::setHeader('Cache-Control', 'max-age=' . $maxage . ', must-revalidate');
         Utilities::setHeader('Pragma', 'cache');
         Utilities::setHeader('Last-Modified', date('D, d M Y H:i:s', $lastModifiedDate) . ' GMT');
         Utilities::setHeader('Expires', date('D, d M Y H:i:s', time() + 60 * 60 * 24 * 90) . ' GMT');
         Utilities::statusCode(200, 'OK');
     }
     return $this;
 }