Nginx и проверка Google. Как ускорить работу сайта: различия между версиями
Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2024
Admin iph (обсуждение | вклад) |
Admin iph (обсуждение | вклад) |
||
Строка 34: | Строка 34: | ||
gzip_min_length 1000; | gzip_min_length 1000; | ||
gzip_proxied any; | gzip_proxied any; | ||
− | gzip_types text/plain text/xml application/xml application/x-javascript text/javascript text/css text/json image/svg+xml; | + | gzip_types text/plain text/xml application/xml application/x-javascript application/javascript text/javascript text/css text/json image/svg+xml; |
gzip_disable "msie6"; | gzip_disable "msie6"; | ||
gzip_comp_level 8; | gzip_comp_level 8; |
Версия 17:11, 26 января 2016
Используйте кеш браузера - nginx (Проверка через Google)
В Nginx кэширование включается инструкцией expires. Добавляем в секцию статики expires max;
# vi /etc/nginx/nginx.conf location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ { expires max; } # /etc/init.d/nginx restart nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful Stopping nginx:. [ OK ] Starting nginx: [ OK ]
Включите сжатие (Проверка через Google)
# vi /etc/nginx/nginx.conf location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ { expires max; gzip on; gzip_min_length 1000; gzip_proxied any; gzip_types text/plain text/xml application/xml application/x-javascript application/javascript text/javascript text/css text/json image/svg+xml; gzip_disable "msie6"; gzip_comp_level 8; }
location / { expires 1d; gzip on; gzip_min_length 1000; gzip_proxied any; gzip_types text/plain text/xml application/xml application/x-javascript application/javascript text/javascript text/css text/json image/svg+xml; gzip_disable "msie6"; gzip_comp_level 8; }
# /etc/init.d/nginx restart nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful Stopping nginx:. [ OK ] Starting nginx: [ OK ]
Чекаем через