Website Performance

Under the Apache web server you can enable a number of modules which will allow you to optimise the performance of your website. Normally when you visit the website, the content needs to be obtained from the website to your browser. If the user is making multiple request to your website, it would mean some static content will be retrieved multiple times. Though the use of browser cache we can load some files from the users local computer and only retrieve the difference from the server.

Apache expires

a2enmod expires

Enabling module expires.
To activate the new configuration, you need to run:
  service apache2 restart

This will enable our website to make use of the Apache module called expires. To use expires we can use the following settings in our .htaccess file.


ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"