Caching

In this chapter described:

1 Introduction

Caching is a cheap and effective way to improve the performance of a web application / portal. By storing relatively static data in cache and serving it from cache when requested, we save the time needed to generate the data.

Using caches in the portal mainly involves configuring and accessing a cache application component. The following application configuration specifies a cache component that uses memcache with two cache servers.


array(
    ......
    'components'=>array(
        ......
        'cache'=>array(
            'class'=>'system.caching.CMemCache',
            'servers'=>array(
                array('host'=>'server1', 'port'=>11211, 'weight'=>60),
                array('host'=>'server2', 'port'=>11211, 'weight'=>40),
            ),
        ),
    ),
);

When the application is running, the cache component can be accessed via Yii::app()→cache. Memcached is the preferred caching system although other caching systems can be used. APC should be used for binary caching of PHP only.

2 Caching in Gentics Portal.Node PHP

Almost every module caches some data. This can be comments, likes, search result etc.

Time of caching can be set in configuration, for each module this variable has the same name ‘cacheTime’:


......
'cacheTime' => 60*60
......

3 How to use cache

You can read more about the topic Yii cache