Apache 2.2 Browser-Caching

If you want to enable the browser cache with the new Apache 2.2, you have to enable the module rewrite first and then to restart the Apache:

sudo a2enmod rewrite && /etc/init.d/apache2 restart

Add this to the File “/etc/apache2/apache2.conf” :

<ifmodule mod_expires.c>
ExpiresActive on
ExpiresByType image/x-icon “access plus 2 month”
ExpiresByType image/png “access plus 2 month”
ExpiresByType image/jpg “access plus 2 month”
ExpiresByType image/gif “access plus 2 month”
ExpiresByType image/jpeg “access plus 2 month”
ExpiresByType application/pdf “access plus 2 month”
ExpiresByType audio/x-wav “access plus 2 month”
ExpiresByType audio/mpeg “access plus 2 month”
ExpiresByType video/mpeg “access plus 2 month”
ExpiresByType video/mp4 “access plus 2 month”
ExpiresByType video/quicktime “access plus 2 month”
ExpiresByType video/x-ms-wmv “access plus 2 month”
ExpiresByType application/x-shockwave-flash “access 2 month”

ExpiresByType text/css “access plus 24 hour”
ExpiresByType text/javascript “access plus 2 hour”
</ifmodule>

This is an example config, for images I choose 2,CSS 1day and for JavaScript 2 Hours from the last access.

Leave a Reply

Your email address will not be published.

9 + eight =