Zend Server User Guide > Tasks > Working with Caching

Working with Caching

This procedure describes the different caching capabilities available to you when using Zend Server. Caching is the process of storing data or pre-rendered web output that can dramatically reduce the time to present results to the users.

The available caching capabilities are:

API versus UI

The first step in choosing a suitable caching option is to discern who should be setting-up the caching.

 

The decision of what caching option to use, is also based on the type of content you are interested in caching. Any long running operations such as query results, can be cached using an API as long as the information is relatively static (i.e. does not frequently change). For example, if you are using a web service to collect weather information you can use the API to cache the information and refresh every few hours and gain a performance boost without compromising the accuracy of your information. When planning to develop a PHP application, long processes should be pinpointed in advance in order to implement caching in an early stage.

 

On the other hand, if you have entire web pages that include static content such as home pages, online stores and catalogs you can cache the entire page using the Page Cache. When you have pages that include a mixture of static information and personalized information you can in essence cache per user but that should be done carefully as it may cancel out the caching performance gain.

 

The last point in deciding is ease of use. Using the Data Cache and the Zend Framework Cache API requires programming skills to insert the API in the code and a deep knowledge of how the PHP application works. Page Caching also requires a deep understanding of how the PHP application works but does not require any programming skills and the entire caching process can be done from the Zend Server User Interface (Rule Management | Caching).

Data Cache API

The Data Cache API is a caching option that is integrated into Zend Server. In terms of value the option provides high performance in memory caching. As it is integrated into Zend Server you also gain a certain amount of control such as the ability to turn on/off the component and manually clear the cache with a click of a button. The Data Cache API is designed with an APC compatibility layer ensuring that extendibility with most APC compatible applications.

 

How it works:

Zend Data Cache is a set of API functions enabling a developer to store and manage data items (PHP strings, arrays and other data) and even output elements in either disk-based cache or shared memory cache. Zend Data Cache allows for precision guided caching when Page Caching is not an option. The provided API is easy-to-use on existing code, and in many cases a developer can skip existing code sections by simply wrapping them with caching APIs.

Page Caching

Page Caching is ideal for cases when you want to avoid programmatic intervention to implement, configure and manage caching capabilities. The integration into Zend Server allows complete control over the caching activity and with relative ease you can add, remove and change caching rules as well as empty the cache with a click of a button.

 

How it works:

Zend Page Cache allows caching of entire PHP web pages, or more correctly put, entire HTTP responses sent out from PHP. Page Caching permits dramatically improving the performance of pages on web applications (sometimes running as high as 10x, 20x and even 100x times faster), while maintaining dynamic capabilities through an elaborate system of caching rules that could be based on request parameters and user session data.

Zend Framework Cache API

The Zend Framework Cache API is a standardized open source caching solution. This grants you the freedom to not only configure it based on your needs but also to contribute extensions and fixes and benefit from contributions from other developers. The Zend framework API has pluggable backends so that you can create a generic implementation and swap the backend with different solutions such as memcache, APC and the Data Cache API. Using the Data Cache API provides an additional advantage as it allows you to use an option that is integrated into Zend Server gain a certain amount of control such as the ability to turn on/off the component and manually clear the cache with a click of a button.

 

Read Also

  Page Cache    
  Data Cache