How to speed up your website (LAMP/WAMP)Dec 23, 2010

In this post I will discuss how to optimize and increase performance of a website.

By following standards, implementing best practices and using few tools and techniques we can significantlyimprove website performance. It is almost impossible to cover all in one post so let's create a list of tipsand we will discuss one by one in detail (in future posts).

  • Try to avoid using .htaccess files unless you don't have access to the main server configuration file.
  • Configure httpd.conf file correctly for best performance, i.e. turn off unnecessary parameters.
  • A static HTML file will be served at least 2 – 10 times faster than a PHP script. Try to use fewer scriptsand more static HTML pages.
  • Compress output (usually by gzip compression).
  • If you frequently use echo or print in your code use output buffering.
  • Try to avoid using file based sessions, use shared memory sessions.
  • If your pages don't changes too frequently try to cache the out as HTML or use proxy server for cache,i.e. Nginx, Squid, Varnish etc.
  • Avoid using images. If necessary to use images then make sure every image is saved by option "Save for web"to reduce your image size.
  • Use CSS sprites for background images.
  • Let google host your libraries, i.e. jqery, dojo, prototype etc.
  • Serve static content from a cookie free domain, i.e. Create a sub-domain for JavaScript, CSS and images.
  • Combine and compress JavaScript and CSS files.
  • Try to put all CSS in head tag and JavaScript at bottom (just before the close body tag).
  • Add proper Cache control headers for images, scripts, CSS, and content.
  • If possible try to distribute workload. Serve Images from another low end server and run your SQL at another.
  • Benchmark your web server, i.e. ab(Apache Benchmark) or WAST(Web Application Stress Tool).
  • Use Firefox add-ons for performance testing, i.e. YSlow or Google page speed.

Assumption: website is hosted on WAMP or LAMP.

blog comments powered by Disqus
Me Hi! My name is Zeeshan Muhammad Khan (nick name Shan) and I am a software engineer, database developer, web developer, programming geek, statistics geek, mathematics geek, system analyst and maintainer of this site. read more

Web Shelf