Пример #1
0
 /**
  * Sets caching mode for the browser
  *
  * @todo implement remaining caching modes
  * @param $mode
  * @param integer $value timestamp in seconds or offset in seconds
  */
 public function setCaching($mode, $value)
 {
     switch ($mode) {
         case 'modified':
             // Last-modified
             $this->response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s', $value) . ' GMT');
         case 'expires':
             // Expire
             $this->response->setHeader('Expires', gmdate('D, d M Y H:i:s', $value) . ' GMT');
             break;
         case 'age':
             // Cache-control: max-age=
             $this->response->setHeader('Cache-control', 'max-age=' . $value);
             break;
         case 'off':
         case FALSE:
             $this->response->setHeader('Cache-control', 'no-cache');
             $this->response->setHeader('Pragma', 'no-cache');
         default:
             throw new Exception('Unknown caching mode: \'' . $mode . '\'');
     }
 }
Пример #2
0
 /**
  * Sets caching mode for the browser
  *
  * @todo implement remaining caching modes
  * @param $mode
  * @param integer $value timestamp in seconds or offset in seconds
  */
 public function setCaching($mode, $value)
 {
     // unresolved artifact from Symfony migration
     throw new \LogicException('Cannot set caching in view without access to response');
     switch ($mode) {
         case 'modified':
             // Last-modified
             $this->response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s', $value) . ' GMT');
         case 'expires':
             // Expire
             $this->response->setHeader('Expires', gmdate('D, d M Y H:i:s', $value) . ' GMT');
             break;
         case 'age':
             // Cache-control: max-age=
             $this->response->setHeader('Cache-control', 'max-age=' . $value);
             break;
         case 'off':
         case FALSE:
             $this->response->setHeader('Cache-control', 'no-cache');
             $this->response->setHeader('Pragma', 'no-cache');
         default:
             throw new \Exception('Unknown caching mode: \'' . $mode . '\'');
     }
 }