Jump to content

Page Caching and compression


alwoodman

Recommended Posts

Hi

 

I have a simple page cacher on my site

 

<?php 
if($_GET['testing'] != 1){
$cachefile = 'cache/index.html';
$cachetime = 3000;
// Serve from the cache if it is younger than $cachetime
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
    include($cachefile);
    exit;
}
ob_start(); 
}
?>

 

but recently came across this update to it which is:

 

<?php 
if($_GET['testing'] != 1){
$cachefile = 'cache/index.html';
$cachetime = 3000;
// Serve from the cache if it is younger than $cachetime
if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {
    include($cachefile);
    exit;
}
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); 
}
?>

 

Could you confirm this script is caching the content of my page and when a user requests it again it's being decompressed? The reason i ask is the output still seems to be the same size in the cache folder with and without this code

 

thanks

 

Lee :confused:

 

Link to comment
https://forums.phpfreaks.com/topic/202156-page-caching-and-compression/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.