Reduce server load using Expires Headers

Expires Headers tells your browser if the requested file should be fetched from the server or from the browsers cache memory. The point of Expires Headers is to reduce the files the user has to download and create a faster experience. The second reason is to reduce the servers load.

Expires Headers also tells how long the files should be fetched from the cache. All necessary resources will be fetched the first time a user visits your website. After the first visit, everything will load a lot faster since the browser won’t bother to download stuff it already has saved locally.

Just add these lines to your .htaccess which should be found in the root of your website.
Maybe something like /srv/users/u_798132/

# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"

Congratulations! You now have a faster website, and hopefully more happy visitors.

Leave a Reply

Your email address will not be published. Required fields are marked *