High page speed and short page load times of your website are essential for good search engine rankings today. In this FAQ, I will show you how to enable caching of graphic and CSS files in apache on Ubuntu and Debian.

The first step is to enable the expires module in apache:

a2enmod headers expires

This module allows the apache web server to set HTTP headers, in this case, to set the modification header for static assets like image and CSS files that don't change often.

Add the following config snippet inside the vhost file of the web site or at the end of the file /etc/apache2/apache2.conf to enable it globally.

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=3024000, public"
</FilesMatch>

Finally reload apache to apply the configuration change.

service apache2 reload

On ISPConfig 3 servers, the snippet can be added in the "Apache Directives" field of the website instead. There is no apache reload required as ISPConfig takes care about that.

Enable image caching in apache for better Google Page Speed results
Tagged on:     

3 thoughts on “Enable image caching in apache for better Google Page Speed results

  • Permalink

    That is the shortest and simlpest way of cache control. Didn’t even spend much time in reading article and it works.

    Thanks

    Reply
  • Permalink

    This is the good informative blog. Linux is the most popular server operating system.

    Reply

Leave a Reply

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

*