Introduction to the Webcache
|
go back to this Tutorial Why do I need this?Right now you might be asking yourself why you even bother reading this. You may not even have trouble with the speed of your website, but it is still a good Idea to think about this cache, especially if you are with a shared hosting provider.
The webcache will help you to significantly reduce the load on the MySQL server AND the webserver, by avoiding costly PHP code execution and MySQL queries. The principle is quite simple: For every node of your CMS a html file will be generated, based on some rules you can set up (I will get into this in the implementation section). If the webserver finds a html file, it will serve this file instead of interpreting php and sending requests to the MySQL servers. This has a few advantages:
CreditsThis cache is based on the implementation by Ben Slade that can be found here. While Bens ingenious cache works very well on news-like websites, where the latest news are always the most requested items, it does not work very well for me. Bens cache only keeps a copy of the last 20 nodes that have been created. For me, I have almost 2000 nodes. Each of them sees about the same amount of visitors on average. While I can not create 2000 nodes every 20 minutes, or I would stress my MySQL server too much (exactly what we want to avoid), I have change the code quite a bit. Here is the highlights of my changes:
Disclaimer and Other thingsEven though the cache works well for me (so far), I do not guarantee that it will work for you. Make backups of your site and your database before messing around with it. Disable all functionality and use the built in log function to look at the unix commands and mysql queries generated before actually enabling the code. I provide this information at no benefit to me and I do not assume any liability for lost data, ruined customer reputation or whatever. You are on your own. That does not mean, that I will completely ignore questions.If you improve the cache, please send me a copy of the improved cache. I will credit you for it on this website. |








Post new comment