Last active
August 29, 2015 14:16
-
-
Save groggu/a384f5a2c3fcfd376edc to your computer and use it in GitHub Desktop.
htaccess file compression and caching settings for Magento
This file contains 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
Update Expires time to increase Browser Caching | |
At the beginning of the <IfModule mod_expires.c> section replace | |
<IfModule mod_expires.c> | |
############################################ | |
## Add default Expires header | |
## http://developer.yahoo.com/performance/rules.html#expires | |
ExpiresDefault "access plus 1 year" | |
</IfModule> | |
with | |
<IfModule mod_expires.c> | |
### START OPT ################################### | |
## Update the expires headers to improve caching | |
## | |
ExpiresActive On | |
ExpiresDefault "access plus 1 seconds" | |
ExpiresByType image/x-icon "access plus 2592000 seconds" | |
ExpiresByType image/jpeg "access plus 2592000 seconds" | |
ExpiresByType image/png "access plus 2592000 seconds" | |
ExpiresByType image/gif "access plus 2592000 seconds" | |
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds" | |
ExpiresByType text/css "access plus 604800 seconds" | |
ExpiresByType text/javascript "access plus 604800 seconds" | |
ExpiresByType application/javascript "access plus 604800 seconds" | |
ExpiresByType application/x-javascript "access plus 604800 seconds" | |
ExpiresByType text/html "access plus 600 seconds" | |
ExpiresByType application/xhtml+xml "access plus 600 seconds" | |
</IfModule> | |
# END Expire headers | |
# BEGIN Cache-Control Headers | |
<ifModule mod_headers.c> | |
<filesMatch "\.(ico|jpe?g|png|gif|swf)$"> | |
Header set Cache-Control "max-age=2592000, public" | |
</filesMatch> | |
<filesMatch "\.(css)$"> | |
Header set Cache-Control "max-age=604800, public" | |
</filesMatch> | |
<filesMatch "\.(js)$"> | |
Header set Cache-Control "max-age=604800, private" | |
</filesMatch> | |
<filesMatch "\.(x?html?|php)$"> | |
Header set Cache-Control "max-age=600, private, must-revalidate" | |
</filesMatch> | |
</ifModule> | |
### END OPT ############################### | |
Enable Test File Compression | |
At the end of the <IfModule mod_deflate.c> section add | |
### START OPT ################################### | |
## compress files to improve site speed | |
## | |
<filesMatch "\.(css|js|x?html?|php)$"> | |
SetOutputFilter DEFLATE | |
</filesMatch> | |
### END OPT ############################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment