Changeset 24554
- Timestamp:
- 11/30/09 11:24:36 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfSuperCachePlugin/branches/1.3/lib/sfSuperCacheFilter.class.php
r24553 r24554 27 27 // execute this filter only if cache is set and no GET or POST parameters 28 28 // execute this filter not in debug mode, only if no_script_name and for 200 response code 29 if ( !sfConfig::get('sf_cache') || count($_GET) || count($_POST) || sfConfig::get('sf_debug') || 30 !sfConfig::get('sf_no_script_name') || $response->getStatusCode() != 200 ) 29 if ( 30 (!sfConfig::get('sf_cache') || count($_GET) || count($_POST)) 31 || 32 (sfConfig::get('sf_debug') || !sfConfig::get('sf_no_script_name') || $response->getStatusCode() != 200) 33 ) 31 34 { 32 35 return; … … 36 39 $cacheManager = $this->getContext()->getViewCacheManager(); 37 40 $uri = $this->getContext()->getRouting()->getCurrentInternalUri(); 38 39 41 if ($cacheManager->isCacheable($uri) && $cacheManager->withLayout($uri)) 40 42 { … … 62 64 if (!is_dir($file)) 63 65 { 66 $response = $this->getContext()->getResponse(); 67 64 68 $expiryDate = time() + $cacheManager->getLifetime($uri); 65 69 // Note: some proxies do cache 302 responses, despite the rfc, so we explicitely ask for no cache 66 $header = $this->getParameter('check_lifetime', true) ? "<?php if (time() > $expiryDate) { unlink(__FILE__); header('Pragma: no-cache'); header('Location: '.\$_SERVER['REQUEST_URI']); exit; } ?>\n" : ''; 67 file_put_contents($file, $header . $this->getContext()->getResponse()->getContent()); 70 if ($this->getParameter('check_lifetime', true)) 71 { 72 $header = sprintf("<?php if (time() > %d) { unlink(__FILE__); header('Pragma: no-cache'); header('Location: '.\$_SERVER['REQUEST_URI']); exit; } ?>\n", $expiryDate); 73 $header .= sprintf("<?php header('Content-Type: %s') ?>\n", $response->getContentType()); 74 foreach(array('Cache-Control', 'Pragma', 'Expires') as $key) 75 { 76 if ($value = $response->getHttpHeader($key)) 77 { 78 $header .= sprintf("<?php header('%s: %s') ?>\n", $key, $value); 79 } 80 } 81 } 82 else 83 { 84 $header = ''; 85 } 86 file_put_contents($file, $header.$response->getContent()); 68 87 chmod($file, 0666); 69 88 } 70 89 umask($current_umask); 71 90 } 72 else73 {74 }75 91 } 76 92 }