Nginx и проверка Google. Как ускорить работу сайта

Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2024
Перейти к:навигация, поиск

Самые выгодные сервера‎ в рунете


Используйте кеш браузера - 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 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 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  ]




The above mentioned content was created by [email protected]