Created
April 29, 2013 21:19
-
-
Save jreinke/5484860 to your computer and use it in GitHub Desktop.
gzip static files when mod_gzip is not available
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
<Files *.js.gz> | |
AddType "text/javascript" .gz | |
AddEncoding gzip .gz | |
</Files> | |
<Files *.css.gz> | |
AddType "text/css" .gz | |
AddEncoding gzip .gz | |
</Files> | |
# Check to see if browser can accept gzip files. | |
RewriteCond %{HTTP:accept-encoding} gzip | |
#RewriteCond %{HTTP_USER_AGENT} !Safari | |
# Make sure there's no trailing .gz on the url | |
RewriteCond %{REQUEST_FILENAME} !^.+\.gz$ | |
# Check to see if a .gz version of the file exists. | |
RewriteCond %{REQUEST_FILENAME}.gz -f | |
# All conditions met so add .gz to URL filename (invisibly) | |
RewriteRule ^(.+) $1.gz [QSA,L] |
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
find . -regex ".*\(css\|js\)$" -exec bash -c 'echo Compressing "{}" && gzip -c --best "{}" > "{}.gz"' \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment