.htaccess Joomla! 6 Joomla! 5 Joomla! 4 Template Basic

Enable Browser Caching (Expires) and Gzip Compression in .htaccess

Sets long-lived browser cache headers for WebP/AVIF images, WOFF2 fonts and versioned CSS/JS plus Gzip compression for fast PageSpeed scores.

Updated on 24 November 2026 57 copies 190 views
.htaccess
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/webp "access plus 1 year"
    ExpiresByType image/avif "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"
    ExpiresByType font/woff2 "access plus 1 year"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
</IfModule>

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/css application/javascript application/json image/svg+xml
</IfModule>
Pair with joomla.asset.json version tags for instant cache invalidation on deploys.

Technical explanation and best practices

Paired with Joomla 5 and 6 WebAssetManager cache-busting query versions, 1-year static asset caching removes redundant network round-trips on repeat visits.

Direct Engineering

Have a Joomla project or technical challenge in mind?

From architectural diagnosis to production deployment, directly with the engineer.