What is Caching and Cache implementation in Zend

Optimization is one of the great thing for making an web application much faster.Although there are various way of optimization .Caching is one of the most efficient  way of optimization of web application. In caching technique basically we store the output somewhere on our file system, memchached server or somewhere else other than our application server . If someone tries to access the same url then instead of creating same output again and again we simply show the output from our cached server or cached files. Here one thing is notable that caching is not beneficial/recommended for all the web application so we must know the recommended condition.

Recommended condition for caching:
Your page content should be stable and doesn’t contain very frequent data changes. We can cache any HTML, XML and images as well

Recommended condition for non caching:
If the output of the page is getting changed at regular interval for example you are showing timer, clock and any such content that is not stable then here caching will make negative impact on your page.

Zend provides a good cache management mechanism through their class Zend_cache.Zend_cache implement caching by frontend and backend adapters. In Frontend adapters we provides options of caching where as in backend adapter we specify the location of cache storage we will elaborate it later on this. In Zend we can implement caching at different level for example :

>> Page cache in Zend: In which we cache the output of entire page without changing the PHP Code. Zend Page caching improves the performance of a page dramatically. But in this caching the problem comes when our page have queristring which gets changed rapidly and result also based on the value of querystring. To overcome this problem and better caching for those URLs we use Output Caching

>> Output Cache in Zend: In this caching mechanism we create a cache the output of the page in Key value form where Key is a unique key generated for each URL  and Value is output of that page.
In this scenario we take full URL with their querystring so that we can cache output of each and every URL even for dynamic querystring as well.

>> Data Cache in Zend: In data cache we store  and manage data items (like array, string, image  etc.) instead of full page output. Zend data caching allows for precision guided caching where page caching is not an option .

Related posts:

The following two tabs change content below.

Chandra Shekhar

GCP Architect
Chandra Shekhar Pandey is Google certified Cloud engineer, I am Magento2 Trained developer. Having huge experience in designing cloud solution. I have around 12 years of experience with world enterprise IT companies and fortune 500 clients. During my architecture design I am always caring about high availability, fast performance and resilient system. From the programmer background I have huge experience in LAMP stack as well. Throughout my carrier I have worked on Retail, E-Learning, Video... Read More about Chandra Shekhar

Latest posts by Chandra Shekhar (see all)