PHP Classes
elePHPant
Icontem

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    
Last Updated Ratings Unique User Downloads Download Rankings
2015-05-12 (4 years ago) RSS 2.0 feedNot yet rated by the usersTotal: 73 All time: 9,474 This week: 713Up
Version License PHP version Categories
php-simple-cache 0.1BSD License4Files and Folders, Cache
Description Author

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.

  Performance   Level  
Name: Dmitry Stroganov <contact>
Classes: 2 packages by
Country: Russian Federation Russian Federation
Age: 40
All time rank: 3733104 in Russian Federation Russian Federation
Week rank: 672 Up23 in Russian Federation Russian Federation Up

 

Details
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  
 0%
Total:73
This week:0
All time:9,474
This week:713Up