PHP Programming/Caching

A cache is a collection of duplicate data, where the original data is expensive to fetch or compute (usually in terms of access time) relative to the cache. In PHP, caching is used to minimize page generation time.

Classification
PHP provides several cache systems :

PHP basically has two main types of caching: 'output caching' and 'parser caching'. PHP 'output caching' saves a chunk of data somewhere that can later be read by another script faster than it can generate it. 'Parser caching' is specific feature. PHP is a scripting language and code is not compiled or optimized to a particular computer. Every PHP file must be parsed and that takes time. This type of time minimization is 'parser caching'.

Include caching
Example:

File:class.test.php

File:program.php

output: Class loaded Hello world! Hello world!

Array caching
Example:

File:program.php

output: sum(0)=0 computed sum(1)=1 computed sum(2)=3 computed sum(3)=6 computed sum(3)=6 from cache sum(4)=10 computed

Session caching
Example:

file:program.php

output: computed My Name is Bill.

output after refresh: cached My Name is Bill.

Shared variables
Example:

file:program.php

output: $this->list[0]["info"]="small info nr 1" $this->list[0]["big"]="" $this->list[0]["info"]="small info nr 1" $this->list[0]["big"]="added big info, maybe structure of objects"

Output Caching
The server cache policy is included into, visible with (with option "I" for header):

Example: