PHP Simple Cache (Miscellaneous)

Introduction

PHP Simple Cache script lets you create cache for any PHP website quickly and easily.

PHP Simple Cache Features

Easy to integrate and configure with any website (just include a file).
Lightweight single file (1.05kb).
Only connects to the database when cache has expired or does not exist.
Set cache lifespan easily.
Ability to delete cached files.
Ability to turn on/off for individual pages.
Makes PHP website responsive.
Reduces server load and resources.
Reduces database queries requests.
Reduces server processing per request.
Increases page loading speed (resulting in better Google Page Rank).

Explanation

Include this 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 you do not want to be cached. If passing a variable or submitting a form, include another single script file to empty cache, so that dynamic functionality of website remains intact.

In short, cache all PHP website, but when performaing a dynamic action on any individual page, refresh cache to ensure site’s stable functionality and optimal performance at the same time.

Its 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 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 coming 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.

Bootstrap was used in this project for styling.

How to Use

Copy cache.php file and cache folder at root directory of your project. Open cache.php file in text editor, change settings for cache folder and cache time and include this file at top of every page of your website. Like below:

$mycache=”on”;
include(“cache.php”);

Or add above code in website’s main db file, configuration file or settings file. That’s it. The cache will work out of the box.

To delete cache or turn cache off for single page, please read implementation file or documentation. Its as simple as $mycache==’on’ or $mycache==’off’.

Download PHP Simple Cache (Miscellaneous)

Leave a Reply

Your email address will not be published. Required fields are marked *