Skip to content

Instantly share code, notes, and snippets.

@pavlo-bondarchuk
Created August 23, 2025 14:45
Show Gist options
  • Save pavlo-bondarchuk/4d7780ceb184a5c6ca55dec9b232615a to your computer and use it in GitHub Desktop.
Save pavlo-bondarchuk/4d7780ceb184a5c6ca55dec9b232615a to your computer and use it in GitHub Desktop.
browser cache for static
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 month"
ExpiresByType image/avif "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType font/woff2 "access plus 1 year"
ExpiresByType font/woff "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/javascript "access plus 1 year"
</IfModule>
<IfModule mod_headers.c>
<FilesMatch "\.(avif|webp|jpe?g|png|gif|svg|css|js|woff2?)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
<FilesMatch "\.(html|php)$">
Header set Cache-Control "no-cache, no-store, must-revalidate"
</FilesMatch>
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment