Last active
August 24, 2022 16:00
-
-
Save cdsaenz/e1b7890dc1ef62b619280e12dd0d05fb to your computer and use it in GitHub Desktop.
.htaccess with expiration/caching settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## EXPIRES CACHING ## | |
## verify module is enabled in apache !!! (expires,headers) ## | |
## ls /etc/apache2/mods-enabled | |
## sudo a2enmod headers | |
## sudo a2enmod expires | |
## sudo /etc/init.d/apache2 restart | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
# Images | |
ExpiresByType image/jpeg "access plus 1 year" | |
ExpiresByType image/gif "access plus 1 year" | |
ExpiresByType image/png "access plus 1 year" | |
ExpiresByType image/webp "access plus 1 year" | |
ExpiresByType image/svg+xml "access plus 1 year" | |
ExpiresByType image/x-icon "access plus 1 year" | |
# Video | |
ExpiresByType video/mp4 "access plus 1 year" | |
ExpiresByType video/mpeg "access plus 1 year" | |
# CSS, JavaScript | |
ExpiresByType text/css "access plus 1 month" | |
ExpiresByType text/javascript "access plus 1 month" | |
ExpiresByType application/javascript "access plus 1 month" | |
# Others | |
ExpiresByType application/pdf "access plus 1 month" | |
ExpiresByType application/x-shockwave-flash "access plus 1 month" | |
ExpiresDefault "access 1 month" | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment