Tag Archives: cache

PHP – check if a file was changed under 10 mins ago

I need to cache results of a PHP glob of a folder…
This folder gets files uploaded via FTP from time to time and I need to prevent the script to perform a glob every time that the page is accessed.

 

$file = 'content.json' ; 
$time = 600 ; //in seconds 

if(!file_exists($file)) 
{ 
  echo 'does not exist' ;
  // lets call the function that makes the glob and create the content.json 
} 
else 
{ 
 if( time() - filemtime( $file ) <= $time ) 
 { 
 echo 'file last changed under 10 mins ago' ; 
 } 
 else 
 { 
 echo 'file last changed more than 10 mins ago' ;
 // lets call the function that makes the glob and create the content.json 
 } 
}

WordPress caching – Quick Cache

I have a bunch of wordpress blogs, two of them getting 1k unique visitor each.

Both of homepage was taking almost 3 seconds to be compiled…
I’v installed a small WordPress Plugin named Quick Cache, to make cache of pages, and from almost 3 seconds now they are served in less that half of a second.

Before Quick Cache plugin

After Quick Cache plugin

History from some tests on the 10th of March and 17th of March.