PHP Simple Cache

PHP Simple Cache


Use PHP Simple Cache to generate and serve static cached pages for PHP websites automatically. Fully configurable, plug and play, extremely easy to use cache script that can be turned on/off for individual pages. Cache can be deleted for single page or all cached pages can be deleted if needed. Speed up website loading time and make your website more responsive, faster, yet always server fresh content to users.

If you like it, please rate it.

PHP Simple Cache - 1PHP Simple Cache - 2PHP Simple Cache - 3PHP Simple Cache - 4PHP Simple Cache - 5

Now updated version automatically clears cache for single page on form submission. You can delete single cached page. Cached pages are stored with distinguishable names with html extension. You can identify which page is cached by its name. In downloadable file, we have included demonstration file to cache pages containing form, session data and variables.

PHP Simple Cache Features

  • Easy to integrate and configure with any website (just include a single file)
  • Use on a live web server or on localhost (wamp, xampp)
  • Lightweight single file script
  • Only connects to the database when cache is cleared, expired or cached page does not exist
  • Ability to set cached pages lifespan
  • Ability to delete cached pages
  • Ability to delete single cached page
  • Ability to turn on/off for individual pages
  • Ability to make PHP website responsive and faster
  • Ability to reduce server load and resources consumption
  • Ability to reduce database requests and connections
  • Ability to reduce web server processing
  • Increase page loading speed (resulting in better Google Page Rank)
  • Easy to use in your existing website
  • Reduce load on Web Services and Database
  • Increase Performance, meet user needs in functionality and application responsiveness
  • Reduce content delivery times by serving content from cache storage


PHP is a programming language to create dynamic websites. Dynamic websites display content that is requested by user. This content changes if user submits form, logs in, sends email, submits comment, add/retrieve data in/from database etc. PHP scripts also retrieve data from database and display it on a dynamic page. Every time such page is loaded in browser, PHP server has to translate PHP script, request database server, retrieve data and then display it for user.

Cache reduces server’s effort. Cache stores a translated version of page (HTML) to display it later. When this page is called again, cache verifies its cached version. If cached copy of page is available and is not expired, it will be displayed and PHP server won’t have to translate PHP scripts and connect to database server to retrieve data. This process reduces server memory usage, server effort snd server resources consumption.

If some kind of dynamic action is performed, old cache is deleted and a new fresh cached copy of page is created for later use. In this way, you website remains up and running at fast speed. A cached version of page is much faster than original dynamic page.

It is logical and based on rule that “Only go through PHP scripts and database if content of page changes. If content is same, store its copy, do not go through PHP scripts and database tables and display cached copy.”

PHP Simple Cache is a small PHP accelerator that substantially increases the speed of PHP website and improves the web page generation process by server. Basically it cahces a page that has been loaded in browser once. Next time cached HTML version of PHP page loads instead of telling PHP server to translate the PHP code again. Similarly, in case of data retrival from database server, it will cache that data and store it in cached file to display it later, instead of connecting to database again.

It enables dynamic PHP pages to load quickly and reduces server load by saving server translated page into cached files and serving that saved data on demand.


Include the main cache script at the top of every page in your website that you want to be cached and that’s it. If not every page, you can also include this script in database file, configuration file or settings file of your project to cache whole website. Turn off cache for individual pages by passing a single variable to the page before including main cache script.

Cache all PHP website, but when performing a dynamic action on any individual page, refresh cache to ensure site’s stable functionality and optimal performance at the same time. We have explained implementation in detail within documentation that comes with the script.

Changes Log

. 24-March-2013

  • Bug fixes, improvements, documentation correction and updates.

. 22-March-2013

  • Cached pages names are modified to understandable name with html extension – Before pages were being saved with a random name without any extension. You can distinguish a page now from different cached pages.
  • Added ability to delete single current page, implementation included
  • Added form, sessions, variables in pages to show demonstration of cache with dynamic content.
  • Added ability to refresh cached page automatically on form submission
  • Updated live demo
  • Updated documentation
  • Updated core cache script

. 05-March-2013

  • Updated live demo
  • Updated documentation
  • Updated core cache script
  • Changed ‘cache folder’ path to absolute path in core script

If you want to cache selected parts of webpage(s), check ‘PHP Metameric Cache’.


Author Image