Commit eae531ec562d0f27615ffc1b0eaf34b5d250212f
1 parent
c7e06a33
gzip
Showing
1 changed file
with
42 additions
and
10 deletions
Show diff stats
.htaccess
| ... | ... | @@ -43,13 +43,45 @@ AddDefaultCharset utf-8 |
| 43 | 43 | RewriteRule \.(htaccess|htpasswd|svn|git) - [F] |
| 44 | 44 | </IfModule> |
| 45 | 45 | |
| 46 | -<ifModule mod_gzip.c> | |
| 47 | - mod_gzip_on Yes | |
| 48 | - mod_gzip_dechunk Yes | |
| 49 | - mod_gzip_item_include file .(html?|txt|css|js|php|pl)$ | |
| 50 | - mod_gzip_item_include handler ^cgi-script$ | |
| 51 | - mod_gzip_item_include mime ^text/.* | |
| 52 | - mod_gzip_item_include mime ^application/x-javascript.* | |
| 53 | - mod_gzip_item_exclude mime ^image/.* | |
| 54 | - mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.* | |
| 55 | -</ifModule> | |
| 56 | 46 | \ No newline at end of file |
| 47 | +<IfModule mod_headers.c> | |
| 48 | + # Serve gzip compressed CSS files if they exist | |
| 49 | + # and the client accepts gzip. | |
| 50 | + RewriteCond "%{HTTP:Accept-encoding}" "gzip" | |
| 51 | + RewriteCond "%{REQUEST_FILENAME}\.gz" -s | |
| 52 | + RewriteRule "^(.*)\.css" "$1\.css\.gz" [QSA] | |
| 53 | + | |
| 54 | + # Serve gzip compressed JS files if they exist | |
| 55 | + # and the client accepts gzip. | |
| 56 | + RewriteCond "%{HTTP:Accept-encoding}" "gzip" | |
| 57 | + RewriteCond "%{REQUEST_FILENAME}\.gz" -s | |
| 58 | + RewriteRule "^(.*)\.js" "$1\.js\.gz" [QSA] | |
| 59 | + | |
| 60 | + | |
| 61 | + # Serve correct content types, and prevent mod_deflate double gzip. | |
| 62 | + RewriteRule "\.css\.gz$" "-" [T=text/css,E=no-gzip:1] | |
| 63 | + RewriteRule "\.js\.gz$" "-" [T=text/javascript,E=no-gzip:1] | |
| 64 | + | |
| 65 | + | |
| 66 | + <FilesMatch "(\.js\.gz|\.css\.gz)$"> | |
| 67 | + # Serve correct encoding type. | |
| 68 | + Header append Content-Encoding gzip | |
| 69 | + | |
| 70 | + # Force proxies to cache gzipped & | |
| 71 | + # non-gzipped css/js files separately. | |
| 72 | + Header append Vary Accept-Encoding | |
| 73 | + </FilesMatch> | |
| 74 | +</IfModule> | |
| 75 | + | |
| 76 | +<IfModule mod_expires.c> | |
| 77 | + # Turn on the module. | |
| 78 | + ExpiresActive on | |
| 79 | + # Set the default expiry times. | |
| 80 | + ExpiresDefault "access plus 2 days" | |
| 81 | + ExpiresByType image/jpg "access plus 1 month" | |
| 82 | + ExpiresByType image/gif "access plus 1 month" | |
| 83 | + ExpiresByType image/jpeg "access plus 1 month" | |
| 84 | + ExpiresByType image/png "access plus 1 month" | |
| 85 | + ExpiresByType image/ico "access plus 1 month" | |
| 86 | + ExpiresByType image/x-icon "access plus 1 month" | |
| 87 | + ExpiresByType text/html "access plus 600 seconds" | |
| 88 | +</IfModule> | |
| 57 | 89 | \ No newline at end of file | ... | ... |