Exemple #1
0
 /**
  * Pre-filter issues cache headers.
  *
  * @param T_Response $response  encapsulated response to filter
  */
 protected function doPreFilter(T_Response $response)
 {
     if ($this->cache_time <= 0) {
         $response->setHeader('Cache-Control', 'no-cache, must-revalidate');
         // HTTP/1.1 uses cache control
         $response->setHeader('Pragma', 'no-cache');
         // HTTP/1.0 uses pragma
         $expiry = time() - 60 * 60 * 24 * 30;
         // expired 30 days ago.
     } else {
         $state = "{$this->type}, max-age={$this->cache_time}, must-revalidate";
         $response->setHeader('Cache-Control', $state);
         $response->setHeader('Pragma', $this->type);
         $expiry = time() + $this->cache_time;
     }
     $date = gmdate('D, d M Y H:i:s \\G\\M\\T', $expiry);
     $response->setHeader('Expires', $date);
 }
Exemple #2
0
 /**
  * Adds Etag and last-modified headers to response.
  *
  * @param T_Response $response  Response to add headers to
  */
 protected function setHeader(T_Response $response)
 {
     $date = gmdate('D, d M Y H:i:s \\G\\M\\T', $this->lm);
     $response->setHeader('Last-Modified', $date);
     $response->setHeader('Etag', $this->getEtag());
 }
Exemple #3
0
 /**
  * Pre-filter starts buffer.
  *
  * @param T_Response $response  encapsulated response to filter
  */
 protected function doPreFilter(T_Response $response)
 {
     $this->response = $response;
     if ($this->isZlibCompressed()) {
         return;
     }
     ob_start();
     if ($this->clientAcceptsCompression()) {
         /* Headers must be sent in the pre-filter.
            (post filter is executed after headers sent) */
         $response->setHeader('Content-Encoding', 'gzip');
     }
 }