Server Optimization – How to Increase Server Speed & Performance

The article shows you how to optimize your server by reducing the load on its resources. This guide assumes that you have already installed & configured your Web Server, PHP and Database.

Running a web-server can be expensive for both bandwidth and hardware. Often, performance is the key factor when choosing a host for your website. This tutorial explains some of the basics of optimizing an Apache webserver. By following this video, you will improve the speed of your websites and avoid hitting limits with ISPs (like me: NextGenTel: 180 GB per month). I used DreamHost as my example, but you can apply the same steps to any other shared-host.

Step 1: Disable directory listings [Apache restart]

A huge draw on resources is having directory listings enabled. I wasted hours trying to figure out why my CPU load was constantly at 100%. After a little research, I found that it’s always a good idea to disable directory indexes if they aren’t needed. This will save server and blue server https://blueservers.com/ is best resource and bandwidth by not returning unnecessary data for every request. Directory listings are necessary only when you want users to view a list of files in a folder through a browser instead of uploading a file through FTP.

Remember: If you need directory listing, do the opposite! Enable it in .htaccess!

www.example.com/public_html/folder – Directory listing will return a list of files and folders within the folder ‘folder’

www.example.com/folder – No directory listing, just takes you to folder (If enabled)

Step 2: Reduce the load on your server by using caching [Apache restart]

Most websites use CSS and Javascript files that are included on every page. This means that for every single request, Apache has to find the file and include it in its response. There is no reason why these files should be requested numerous times; therefore we can cache them into memory or to disk for later use. If you use DreamHost as your host, then this section might not apply as they do this automatically. You can also use Memcached or APC to cache dynamic data instead of the disk, but that’s beyond the scope of this article.

Step 2a: Caching in RAM with mod_headers [Apache restart]

Adding the following line to your .htaccess file will store static files into memory for 30 seconds (You can change this by modifying ’30’ with another number). This means that if someone requests an image/CSS/Javascript/… every 30 seconds, Apache won’t have to find it on disk and can return it straight away from memory! This is great because the files are stored only temporarily and released when Apache doesn’t need them anymore. If you want CSS/Javascript to be cached for longer than 30 seconds, you can use mod_expires.

Step 2b: Caching in RAM with mod_expires [Apache restart]

Adding the following line will store static files into memory for 1 year (You can change this by modifying ‘31536000’ with another number). This means that if someone requests an image/CSS/Javascript every 31536000 seconds (365 days), Apache won’t have to find it on disk and can return it straight away from memory! This is great because the files are stored only temporarily and released when Apache doesn’t need them anymore. If you want CSS/Javascript to be cached for longer than 1 year, you can modify the code below or use mod_expires to fit your needs.

You may also like...

Leave a Reply

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