Simple caching

hi, i want to add a simple caching to a blog demo. It should make a static copy of a page, so the PHP will not be called before viewing the page. I thought of creating filter with a postFilter method whitch should make that copy…but the problem is that i dont know how to do this :unsure: can anybody give me some suggestions? thx in advance!

This is only beneficial if you have really-really huge traffic. (Like, your site is in the top 100.)

Technically, it is done by web server: it checks the URL against the set of cached pages, and in case of cache hit, PHP won’t be executed. Full page caching is quite simple with Yii, so that’s not the part you’re looking for.

Thank you for you answer.

I have read in guide about caching and i have tryied CFileCache, it seemed to work fine. But still, how could i make static copy of some page and save it in file system…? Any sugestion will be much appreciated. :)

I don’t remenber where I saw this solution.

But it envolves php to generate static HTML of the page you want to cache. And then work on .htaccess of apache to call theses .html.

Apache verify if html exists, if exists it ignores php and call the file directly. If not, the page is called normaly.

I’ll try to find this solution.

I think I found it:

Original link: http://blog.astrumfutura.com/archives/380-Zend-Framework-Page-Caching-Part-1-Building-A-Better-Page-Cache.html

Google cached: (It gives me an error)

http://64.233.163.132/search?q=cache:lFlB1OykqecJ:blog.astrumfutura.com/archives/380-Zend-Framework-Page-Caching-Part-1-Building-A-Better-Page-Cache.html+Zend+Framework+Page+Caching+Building+Better+Page+Cache&cd=1&hl=pt-BR&ct=clnk&gl=br

CFileCache is good. It gives a good performance.

In the config file:


'cache' => array('class' => 'CFileCache'),

Create a Base controller, or any controller you want to test:


<?php

	class AppController extends CController

	{

		public $metaDescricao = null;


		public function filters()

		{

			return array(

				array(

					'COutputCache',

					'duration'=>100

				),

			);

		}

	}

You should also read:

This is not a complete solution, you need to test it.

You must configure it well, byParam, Post, Get etc etc… or you will have diffent Url for the same content.