PHP Classes

PHP Simple Cache: Retrieve the current page from a cache file

Recommend this page to a friend!
  Info   View files Example   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 74 All time: 10,043 This week: 713Up
Version License PHP version Categories
php-simple-cache 0.1BSD License4Files and Folders, Cache


This class can store and retrieve the current page from a cache file.

It can compute an hash from the current page request URL to determine the name of a cache file on which the current page content will be stored.

The class returns the the cache file contents if it already exists and if it was not created more than a given cache expiry timeout period.

Otherwise the class can create a new cache file using the same file name based on the current request URL.

The cache file directory path is based on the first letter of the cache file name and the base cache file path. If the cache directory does not exist, the class creates it.

The cache file base directory path and the expiry time are configurable parameters.

Picture of Dmitry Stroganov
  Performance   Level  
Name: Dmitry Stroganov <contact>
Classes: 2 packages by
Country: Russian Federation Russian Federation
Age: 43
All time rank: 3661103 in Russian Federation Russian Federation
Week rank: 438 Up19 in Russian Federation Russian Federation Up

If your site has mostly static content and you do not want to setup nginx or do not have enough permissions (for example virtual hosting) you may find this class useful for you. Especially if your site more than 5 000 unique visitors per day, your hosting type is virtual hosting, your hosting provider start saying that you better upgrade to VPS/VDS and you do not want to pay more. Steps to use: create a folder named cache in the httpdocs folder of your site, copy cache.php into it, configure path and timeout in the constructor of the class and take a look at the example file attached to this class.
  Files folder image Files  
File Role Description
Files folder imagecache (1 file)
Accessible without login Plain text file index.php Example Sample usage
Accessible without login Plain text file readme.txt Doc. Readme file

  Files folder image Files  /  cache  
File Role Description
  Plain text file cache.php Class Main class

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:10,043
This week:713Up