CentOS 6.4 Speed Up Your Website

I often get asked how to speed up a website. Here are 2 of the easiest and quickest ways to dramatically improve the performance of your website. I am assuming you have root access to either your VPS or CentOS installation. Let's begin:

Edit the file /etc/httpd/conf/httpd.conf

Find:

KeepAliveTimeout

Change To:

KeepAliveTimeout 100

Close and save the httpd.conf file.

Now to go the root of your website and create a .htaccess file. The path to my website is /var/www/html/myawesomesite/public but yours could be different. Now edit your newly created .htaccess file and paste the following:

# compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent

Close and save your .htaccess file.

Now we need to restart our apache web server for the changes to take effect with the following command:

service httpd restart graceful

All done! Now test to see if your performance has improved.

No Comments Yet.

Leave a comment


Sign up to our newsletter where you’ll receive notices on when we post new articles and helpful “how tos” to make your IT life easier.