public function beforeDispatch(Event $event) {
		if (Configure::read('Cache.check') === false) {
			return null;
		}

		/** @var \Cake\Network\Request $request */
		$request = $event->data['request'];

		$url = $request->here();
		$url = str_replace($request->base, '', $url);
		$file = $this->getFile($url);

		if ($file === null) {
			return null;
		}

		$cacheContent = $this->extractCacheContent($file);
		$cacheInfo = $this->extractCacheInfo($cacheContent);
		$cacheTime = $cacheInfo['time'];

		if ($cacheTime < time() && $cacheTime != 0) {
			unlink($file);
			return null;
		}

		/** @var \Cake\Http\Response $response */
		$response = $event->data['response'];
		$event->stopPropagation();

		$response->modified(filemtime($file));
		if ($response->checkNotModified($request)) {
			return $response;
		}

		$pathSegments = explode('.', $file);
		$ext = array_pop($pathSegments);
		$this->_deliverCacheFile($request, $response, $file, $ext);
		return $response;
	}
public function beforeDispatch(Event $event) {
		if (Configure::read('Cache.check') === false) {
			return null;
		}

		/** @var \Cake\Network\Request $request */
		$request = $event->data['request'];

		$url = $request->here();
		$url = str_replace($request->base, '', $url);
		$file = $this->getFile($url);

		if ($file === null) {
			return null;
		}

		$cacheContent = $this->extractCacheContent($file);
		$cacheInfo = $this->extractCacheInfo($cacheContent);
		$cacheTime = $cacheInfo['time'];

		if ($cacheTime < time() && $cacheTime != 0) {
			unlink($file);
			return null;
		}

		/** @var \Cake\Http\Response $response */
		$response = $event->data['response'];
		$event->stopPropagation();

		$response->modified(filemtime($file));
		if ($response->checkNotModified($request)) {
			return $response;
		}

		$pathSegments = explode('.', $file);
		$ext = array_pop($pathSegments);
		$this->_deliverCacheFile($request, $response, $file, $ext);
		return $response;
	}
public function beforeDispatch ( Event $ event ) { if ( Configure :: read ( 'Cache.check' ) === false ) { return null ; } /** @var \Cake\Network\Request $request */ $ request = $ event -> data [ 'request' ] ; $ url = $ request -> here ( ) ; $ url = str_replace ( $ request -> base , '' , $ url ) ; $ file = $ this -> getFile ( $ url ) ; if ( $ file === null ) { return null ; } $ cacheContent = $ this -> extractCacheContent ( $ file ) ; $ cacheInfo = $ this -> extractCacheInfo ( $ cacheContent ) ; $ cacheTime = $ cacheInfo [ 'time' ] ; if ( $ cacheTime < time ( ) && $ cacheTime != 0 ) { unlink ( $ file ) ; return null ; } /** @var \Cake\Http\Response $response */ $ response = $ event -> data [ 'response' ] ; $ event -> stopPropagation ( ) ; $ response -> modified ( filemtime ( $ file ) ) ; if ( $ response -> checkNotModified ( $ request ) ) { return $ response ; } $ pathSegments = explode ( '.' , $ file ) ; $ ext = array_pop ( $ pathSegments ) ; $ this -> _deliverCacheFile ( $ request , $ response , $ file , $ ext ) ; return $ response ; }
Checks if a requested cache file exists and sends it to the browser

@param \Cake\Event\Event $event containing the request and response object

@return \Cake\Http\Response|null Response if the client is requesting a recognized cache file, null otherwise
Checks if a requested cache file exists and sends it to the browser