Ciao.
Questo è un semplice esempio di caching:
Codice PHP:
function writeCache($data,$cacheFile='default_cache.txt')
    if(!
$fp=fopen($cacheFile,'w')){
         
trigger_error('Error opening cache file');
         exit();
    }
    if(!
flock($fp,LOCK_EX)){
        
trigger_error('Unable to lock file');
        exit();
    }
    if(!
fwrite($fp,serialize($data))){
        
trigger_error('Error writing to cache file');
        exit();
    }
    
flock($fp,LOCK_UN);
    
fclose($fp);
}
function 
readCache($cacheFile){
     if(!
file_exists($cacheFile)){
         
trigger_error('Invalid cache file');
         exit();
     }
     return 
unserialize(file_get_contents($cacheFile));
}
function 
connectMySQL($host,$user,$password,$database){
    if(!
$db=mysql_connect($host,$user,$password)){
         
trigger_error('Error connecting to the server '.mysql_error());
         exit();
    }
    if(!
mysql_select_db($database,$db)){
        
trigger_error('Error selecting database '.mysql_error());
        exit();
    }
}
function 
query($query){
    if(!
$result=mysql_query($query)){
        
trigger_error('Error performing query '.$query.mysql_error());
        exit();
    }
    return 
$result;

}
// define cache file
$cacheFile='cacheFile.txt';
// define expire time in seconds (2 hours)
$expireTime=7200;
// check to see if cache file is valid (time triggered caching)
if(file_exists($cacheFile)&&filemtime($cacheFile)>(time()-$expireTime)){
    
// read data from cache file
    
$data=readCache($cacheFile);
}
else{
    
// read data from MySQL
    
connectMySQL('host','user','password','databasename');
    
$result=query('SELECT * FROM users');
    
// store result set in array
    
while($row=mysql_fetch_array($result,MYSQL_ASSOC)){
         
$data[]=$row;
    }
    
// store serialized data in cache file
    
writeCache($data,$cacheFile);
}
// display data
foreach($data as $key=>$row){
    echo 
'First Name :'.$row['firstname'].' Last Name :'.$row['lastname'].'
'
;

La spiegazione la puoi trovare qui

Ad occhio nel post non hai molto le idee chiare.

Ti faccio il mio esempio prima di arrivare alla compressione
(in cui per la verità sono ben poco ferrato dando un occhio
in giro ho trovato pareri contrastanti manuel Lemos di phpclasses.org
ad esempio suggerisce di usare un utiliti per Apache)

Recupero i dati da Db o xml o file
li serializzo con una classe per il caching
con questi faccio la paginazione con un altra classe
creo l'output e poi lo comprimo prima di spedirlo
al browser.