Reference »

How to ensure that browsers properly cache assets on your site

This is how I configure Apache to set cache-control headers for cacheable assets. (The code below is placed in the .htaccess file of every wiki on OborWiki.)

# One month for most static assets
<filesMatch ".(css|jpg|jpeg|png|gif|js|ico|ttf|otf|svg)$">
Header set Cache-Control "max-age=2628000, public"
</filesMatch>

# BEGIN EXPIRES
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 10 days"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType text/html "access plus 1 second"
    ExpiresByType text/plain "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
# END EXPIRES