Virginia Beach Web Development | Website Developer | Mobile Dev | Mobile Video Integration | Doodersrage

Just about everything Website Development related. Virginia Beach VA headquartered with a global reach!

Add Zend Framework full page cache to your bootstrap

Posted on | January 24, 2012 | No Comments

ZendFramework logo 300x79 Add Zend Framework full page cache to your bootstrap

Insert the function below into your bootstrap file.

// full page cache
protected function _initCache()
    {

	$dir = "location you would like to store cached pages";

        $frontendOptions = array(
            'lifetime' => 3600,
            'content_type_memorization' => true,
			'default_options'           => array(
			'cache' => true,
			'cache_with_get_variables' => true,
			'cache_with_post_variables' => true,
			'cache_with_session_variables' => true,
			'cache_with_cookie_variables' => true,
            ),
        'regexps' => array(
                // cache the whole IndexController
                '^/.*' => array('cache' => true),
                '^/index/' => array('cache' => true),
		// place more controller links here to cache them
                 )
        );

        $backendOptions = array(
                'cache_dir' =>$dir
        );

        // getting a Zend_Cache_Frontend_Page object
        $cache = Zend_Cache::factory('Page',
                             'File',
                             $frontendOptions,
                             $backendOptions);

        $cache->start();
    }

Assign the directory that you would like to store the cache files to the -$dir- variable. Make sure the assigned directory can be read and written to. Also add some more controller regular expressions for the extra controllers you would like to also cache to the -regexps- array.

Once setup your pages will automatically be cached to a static cache file at your assigned location on your server for an hour. If you would like to cache the files for longer than an hour, increase the -lifetime- associative array value by increasing the seconds count.

Comments

Leave a Reply





  • Social

    twitter facebook flickr google youtube stumble upon reddit digg
  • Portfolio

    Migrated client from Yahoo shops to osCommerce, moving over website design from old site to new as much as possible.
  • Twitter

  • My Tumblr

    • photo from Tumblr

      Double sunny side up eggs with bacon and shredded potatoes cooked in baconĀ grease.


    • photo from Tumblr

      Afterlife Ghost Pepper Sauce


  • Alexa Rank