Gzip, Brotli, and Browser Cache SetupApache Example
Apache Example
If your server uses Apache and compression is not already enabled, a server admin can review a standard setup like this:
apache
apache1<IfModule mod_deflate.c>2AddOutputFilterByType DEFLATE text/plain3AddOutputFilterByType DEFLATE text/html4AddOutputFilterByType DEFLATE text/css5AddOutputFilterByType DEFLATE text/javascript6AddOutputFilterByType DEFLATE application/javascript7AddOutputFilterByType DEFLATE application/x-javascript8AddOutputFilterByType DEFLATE application/json9AddOutputFilterByType DEFLATE application/xml10AddOutputFilterByType DEFLATE image/svg+xml11</IfModule>1213<IfModule mod_expires.c>14ExpiresActive On15ExpiresByType text/css "access plus 1 month"16ExpiresByType application/javascript "access plus 1 month"17ExpiresByType image/jpeg "access plus 1 year"18ExpiresByType image/png "access plus 1 year"19ExpiresByType image/webp "access plus 1 year"20ExpiresByType image/svg+xml "access plus 1 year"21ExpiresByType font/woff2 "access plus 1 year"22</IfModule>2324<IfModule mod_headers.c>25<FilesMatch "\.(css|js|jpg|jpeg|png|webp|svg|woff2)$">26Header set Cache-Control "public, max-age=2592000"27</FilesMatch>28</IfModule>
Notes:
Some hosts already set these rules globally.
Some managed hosts block custom
.htaccessrules.If your site already has caching rules, merge carefully rather than pasting duplicate blocks.
Continue reading