Created
June 5, 2013 20:22
-
-
Save sms-system/5716991 to your computer and use it in GitHub Desktop.
Ускорение загрузки сайта за счёт кэширования и gzip сжатия
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
Options +FollowSymlinks | |
RewriteEngine On | |
RewriteBase / | |
AddEncoding gzip .gz | |
RewriteCond %{HTTP:Accept-encoding} !gzip | |
RewriteRule ^(.*)\.(css|js)?$ $1.src.$2 [QSA,L] | |
RewriteCond %{HTTP_USER_AGENT} Konqueror | |
RewriteRule ^(.*)\.(css|js)?$ $1.src.$2 [QSA,L] | |
<IfModule mod_headers.c> | |
<FilesMatch .*\.(js|css)$> | |
Header set Content-Encoding: gzip | |
Header set Cache-control: private | |
</FilesMatch> | |
<FilesMatch .*\.src\.(js|css)$> | |
Header unset Content-Encoding | |
</FilesMatch> | |
</IfModule> | |
<IfModule mod_expires.c> | |
ExpiresActive On | |
ExpiresDefault "access 7 days" | |
ExpiresByType application/javascript "access plus 1 year" | |
ExpiresByType text/javascript "access plus 1 year" | |
ExpiresByType text/css "access plus 1 year" | |
ExpiresByType text/html "access plus 7 day" | |
ExpiresByType text/x-javascript "access 1 year" | |
ExpiresByType image/gif "access plus 1 year" | |
ExpiresByType image/jpeg "access plus 1 year" | |
ExpiresByType image/png "access plus 1 year" | |
ExpiresByType image/jpg "access plus 1 year" | |
ExpiresByType image/x-icon "access 1 year" | |
ExpiresByType application/x-shockwave-flash "access 1 year" | |
</IfModule> | |
<ifModule mod_headers.c> | |
Header append Vary User-Agent | |
<filesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|css|js)$"> | |
Header set Cache-Control "max-age=2592000, public" | |
</filesMatch> | |
<filesMatch "\.(xml|txt|html|htm|php)$"> | |
Header set Cache-Control "max-age=172800, private, must-revalidate" | |
</filesMatch> | |
<FilesMatch "\.(js|css|xml|gz)$"> | |
Header set Vary: Accept-Encoding | |
</FilesMatch> | |
</ifModule> | |
FileETag MTime Size | |
<ifModule mod_expires.c> | |
<FilesMatch ".(jpg|jpeg|gif|png|ico|css|js)$"> | |
ExpiresActive on | |
ExpiresDefault "access plus 1 year" | |
</FilesMatch> | |
</ifModule> | |
<IfModule mod_setenvif.c> | |
BrowserMatch "MSIE" force-no-vary | |
BrowserMatch "Mozilla/4.[0-9]{2}" force-no-vary | |
</IfModule> | |
<IfModule mod_deflate.c> | |
AddOutputFilterByType DEFLATE application/javascript | |
AddOutputFilterByType DEFLATE text/javascript | |
AddOutputFilterByType DEFLATE text/css | |
AddOutputFilterByType DEFLATE text/html | |
AddOutputFilterByType DEFLATE text/xml | |
<IfModule mod_setenvif.c> | |
BrowserMatch ^Mozilla/4 gzip-only-text/html | |
BrowserMatch ^Mozilla/4\.0[678] no-gzip | |
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html | |
</IfModule> | |
</IfModule> | |
php_flag zlib.output_compression On | |
php_value zlib.output_compression_level 5 | |
RewriteCond %{HTTP_HOST} . | |
RewriteCond %{HTTP_HOST} !^site\.ru [NC] | |
RewriteRule (.*) http://site.ru/$1 [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment