Decreasing Server Load

Optimizing your server and the server side language used will decrease the time leading up to the client downloading data from the server. An inefficient script can cause major delays on files being served and add a lot of extra load on the server. If many users are browsing the site, this can cause the server to lag even more and eventually crash.

Obviously, if you are a programmer, optimizing the script will make the server more efficient and less likely to lag or crash. However, even a well optimized script can still be very taxing on the server’s resources. On this page we will discuss a simple technique for reducing the load on the server for all users.

Server-Side Cache

Say you have a PHP script that is parsing an XML feed and displaying the information on your website. If the feed source is not updated continuously, there is no reason to continuously parse the feed for new information. This is where cache comes in very handy. By writing the output of your script to a file on your server, this information can be used instead of reparsing the feed for new content.

First, have the sript check if the file exists, and at what time the file was last modified. If enough time has passed since the file was last modified, parse the feed again for new content and write the output to the cache file. If the time limit you’ve defined has not been passed, simply include the cache file contents. The result of this simple method with allow a potentially infinite number of users to browse the website simultaneously without having to reparse the feed file. Every x amount of time only a single user will be delayed by reparsing the feed and updating the cache file!

With the release of Zen Cart 2.0, the cache system will be greatly improved. In the meantime, Rubik Integration has released a module called Simple Cache which allows blocks of HTML to be cached and loaded in place of all the PHP functions that would need to be executed to create that same block of HTML code. We currently use this module on the website and recommend anyone with an understanding of PHP to give this great developer tool a try.

One thought on “Decreasing Server Load

Leave a Reply

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

    Chat with us Contact Account Cart Search Cart Open Close Menu Arrow Link Arrow Chat