CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.2 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.2
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • AssetDispatcher
  • CacheDispatcher
 1: <?php
 2: /**
 3:  * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 4:  * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 5:  *
 6:  * Licensed under The MIT License
 7:  * Redistributions of files must retain the above copyright notice.
 8:  *
 9:  * @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
10:  * @link http://cakephp.org CakePHP(tm) Project
11:  * @since CakePHP(tm) v 2.2
12:  * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
13:  */
14: 
15: App::uses('DispatcherFilter', 'Routing');
16: 
17: /**
18:  * This filter will check wheter the response was previously cached in the file system
19:  * and served it back to the client if appropriate.
20:  *
21:  * @package Cake.Routing.Filter
22:  */
23: class CacheDispatcher extends DispatcherFilter {
24: 
25: /**
26:  * Default priority for all methods in this filter
27:  * This filter should run before the request gets parsed by router
28:  *
29:  * @var int
30:  */
31:     public $priority = 9;
32: 
33: /**
34:  * Checks whether the response was cached and set the body accordingly.
35:  *
36:  * @param CakeEvent $event containing the request and response object
37:  * @return CakeResponse with cached content if found, null otherwise
38:  */
39:     public function beforeDispatch($event) {
40:         if (Configure::read('Cache.check') !== true) {
41:             return;
42:         }
43: 
44:         $path = $event->data['request']->here();
45:         if ($path == '/') {
46:             $path = 'home';
47:         }
48:         $path = strtolower(Inflector::slug($path));
49: 
50:         $filename = CACHE . 'views' . DS . $path . '.php';
51: 
52:         if (!file_exists($filename)) {
53:             $filename = CACHE . 'views' . DS . $path . '_index.php';
54:         }
55:         if (file_exists($filename)) {
56:             $controller = null;
57:             $view = new View($controller);
58:             $result = $view->renderCache($filename, microtime(true));
59:             if ($result !== false) {
60:                 $event->stopPropagation();
61:                 $event->data['response']->body($result);
62:                 return $event->data['response'];
63:             }
64:         }
65:     }
66: 
67: }
68: 
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs