Development

Changeset 4559

You must first sign up to be able to contribute.

Changeset 4559

Show
Ignore:
Timestamp:
07/08/07 17:36:14 (2 years ago)
Author:
fabien
Message:

fixed Status code 404 may be transformed into 304 when using ETag (closes #1944)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0/lib/filter/sfCacheFilter.class.php

    r3502 r4559  
    108108  { 
    109109    // cache only 200 HTTP status 
    110     if ($this->response->getStatusCode() == 200) 
    111     { 
    112       $uri = sfRouting::getInstance()->getCurrentInternalUri(); 
    113  
    114       // save page in cache 
    115       if ($this->cache[$uri]['page']) 
    116       { 
    117         // set some headers that deals with cache 
    118         $lifetime = $this->cacheManager->getClientLifeTime($uri, 'page'); 
    119         $this->response->setHttpHeader('Last-Modified', $this->response->getDate(time()), false); 
    120         $this->response->setHttpHeader('Expires', $this->response->getDate(time() + $lifetime), false); 
    121         $this->response->addCacheControlHttpHeader('max-age', $lifetime); 
    122  
    123         // set Vary headers 
    124         foreach ($this->cacheManager->getVary($uri, 'page') as $vary) 
    125         { 
    126           $this->response->addVaryHttpHeader($vary); 
    127         } 
    128  
    129         $this->setPageCache($uri); 
    130       } 
    131       else if ($this->cache[$uri]['action']) 
    132       { 
    133         // save action in cache 
    134         $this->setActionCache($uri); 
    135       } 
     110    if (200 != $this->response->getStatusCode()) 
     111    { 
     112      return; 
     113    } 
     114 
     115    $uri = sfRouting::getInstance()->getCurrentInternalUri(); 
     116 
     117    // save page in cache 
     118    if ($this->cache[$uri]['page']) 
     119    { 
     120      // set some headers that deals with cache 
     121      $lifetime = $this->cacheManager->getClientLifeTime($uri, 'page'); 
     122      $this->response->setHttpHeader('Last-Modified', $this->response->getDate(time()), false); 
     123      $this->response->setHttpHeader('Expires', $this->response->getDate(time() + $lifetime), false); 
     124      $this->response->addCacheControlHttpHeader('max-age', $lifetime); 
     125 
     126      // set Vary headers 
     127      foreach ($this->cacheManager->getVary($uri, 'page') as $vary) 
     128      { 
     129        $this->response->addVaryHttpHeader($vary); 
     130      } 
     131 
     132      $this->setPageCache($uri); 
     133    } 
     134    else if ($this->cache[$uri]['action']) 
     135    { 
     136      // save action in cache 
     137      $this->setActionCache($uri); 
    136138    } 
    137139 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.