Using Expires Headers to improve performance

Adding an Expires header to your website with a date in the future makes the files cacheable, reducing the load time of your pages. This should be done with images, but that's fairly typical. Go a step further and add it to scripts and stylesheets, too. This won't affect performance the first time users hit your page, but on subsequent page views it could reduce response times by 50% or more.

Here's an example configuration for your .htaccess file enabling Expires headers on common file types.

 

# Set long expire headers for better browser caching
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/css "access plus 30 days"
ExpiresByType text/javascript "access plus 7 days"
ExpiresByType application/x-javascript "access plus 7 days"
ExpiresByType application/javascript "access plus 7 days"
ExpiresByType image/x-icon "access plus 7 days"
ExpiresByType image/vnd.microsoft.icon "access plus 7 days"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/gif "access plus 30 days"
ExpiresByType image/jpeg "access plus 30 days"
ExpiresByType image/jpg "access plus 30 days"
ExpiresByType application/x-shockwave-flash "access plus 30 days"
</IfModule>

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Optimizing your website via cPanel

You can quickly and simply improve the performance of your website by going to your cPanel at...

Performance tips from Google

Google have collected together lots of very useful tips and tutorials in optimizing your...

Search Engines and Performance

Search Engines such as Google, Yahoo and Microsoft Live Search (or Bing) are very useful at...

High Server Load

High server load can be caused by a number of problems such as high CPU load, high memory usage...

Improving Wordpress performance

Wordpress can be a significant drain on a server's resources if badly configured. Here's some...