In this post I will show you how to create a simple cache system for all your CSB scripts V.2.0 and up, you can add it to older versions also, just ask me how by opening a ticket. It will cache the index page, pagination, categories and the gallery pages allowing you to serve cached files to users wich will greatly reduce the load on your server since no MySQl queries will be made anymore, pages will also be shown to the user faster. Of coarse adding a cache system will only help you out once you have some traffic hitting your site.
The only technical requirement is that Apache needs the ability to create cache files into the cache folder. On all the server this code was tested, I never had to change the cache folder permission. But if for whatever reason your server doesn’t allow the creation of those files, I will show you how to solve it without having to change the cache folder permission.
In each cache code you will find the following line of PHP code. The number 180 is the expiration time of each cache file, it’s in seconds, so 180 means 3 X 60 seconds; so basically 3 minutes. You can raise that value, just don’t raise it too high; you might end up showing offline models…
$cache_time = 180;
The Index Page
First create a /cache/ folder in the root of your domain name so that its path looks like: yourdomain.com/cache/.
Then using your FTP client or file manager open the index.php file located in the root of your domain name.
Now let’s start adding the PHP code in order to create a caching system; on top of the file look for this:
Now for Versions up to 2.3 replace it with this code:
For Versions 2.3 and up replace it with this code:
Then scroll down to the end of the index.php file and look for this: