Improve Site Performance Server Side
Written by james, on date Wed 14 Sep 2011.Part II
This is the second part of a series of blog posts about improving site performance. In the first post (Benchmarking and Improvement With Page Speed Plugin) we discussed how you could benchmark the performance of your site using the Google Page Speed plugin for Mozilla FireFox. In this post, I will discuss how you can use some of the feedback from Page Speed to improve your overall site performance server side.
There are two important concepts that you need to know in order to get the best results.
- Caching - Each site element can be stored temporarily on the end-users disk. Each of those elements (javascript, css, html, images, etc.) has an expiration. Implementing this will greatly decrease bandwidth, because the number of requests will decrease.
- Compression - To put it simple, compression is a reduction in file size. Logically, if things are smaller they are much faster to download.
Ok. So, now that you have an understanding of the concepts above, it should be apparent what we are trying to accomplish. We will try to reduce bandwidth by decreasing file size and by letting your visitors temporarily store various elements of your site on their local disk. For this we will be using mod_expires (caching) and mod_deflate (compression) in conjunction with your Apache installation.
I am not going to go into detail about how to install either module (you can definitely contact me if you need help). Instead, I will be covering a good configuration for both.
mod_expires - Allows you to set an expiration for each site element to be stored locally (cached) on a visitors disk.
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A300
ExpiresByType image/x-icon A6048000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType image/jpeg A604800
ExpiresByType text/plain A300
ExpiresByType application/x-shockwave-flash A604800
ExpiresByType video/x-flv A2592000
ExpiresByType application/pdf A300
ExpiresByType text/html A300
</IfModule>
Analysis:
ExpiresByTypeimage/x-icon A6048000
The file type that you are setting the expiration for.
ExpiresByTypeimage/x-icon A6048000
The time that the file will live in cache before the cache will update or unless the cache is cleared (in which case it starts all over).
mod_deflate - Compresses (decreases size; ultimately decreasing the bandwidth required to download) the various elements of your site.
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
Both of these can be implemented directly in your .htaccess file. Now… if you do not use a shared hosting plan, this will be much easier to implement. On the flip side; if you do have a shared hosting plan, you may not be able to do this at all, but your hosting provider may have already done so. Get some feedback from Page Speed to determine whether or not your server is working in your favor.
Site Map | Products | Contact
© 2011 Johnny Overkill Inc.