×ðÁú¿­Ê±¹ÙÍøµÇ¼

Nginx´î½¨Ð§ÀÍÆ÷µÄ¾²Ì¬×ÊÔ´ÓÅ»¯ºÍ¶¯Ì¬ÄÚÈÝ»º´æ¼¼ÇÉÏê½â

nginx´î½¨Ð§ÀÍÆ÷µÄ¾²Ì¬×ÊÔ´ÓÅ»¯ºÍ¶¯Ì¬ÄÚÈÝ»º´æ¼¼ÇÉÏê½â

Ò»¡¢Ð¡Ðò

NginxÊÇÒ»¸ö¸ßÐÔÄܵÄHTTPºÍ·´ÏòÊðÀíЧÀÍÆ÷ £¬ÆÕ±éÓ¦ÓÃÓÚ¹¹½¨Îȹ̺͸ßЧµÄwebЧÀÍ¡£ÔÚʹÓÃNginx´î½¨Ð§ÀÍÆ÷ʱ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýһЩÓÅ»¯»ººÍ´æ¼¼ÇÉÀ´ÌáÉýÆäÐÔÄܺÍЧÂÊ £¬Ìṩ¸üºÃµÄÓû§ÌåÑé¡£

±¾ÎĽ«ÏêϸÏÈÈÝÔõÑùʹÓÃNginx¾ÙÐо²Ì¬×ÊÔ´ÓÅ»¯ºÍ¶¯Ì¬ÄÚÈÝ»º´æ £¬°üÀ¨ÉèÖûº´æÓâÆÚʱ¼ä¡¢ÆôÓÃgzipѹËõ¡¢É趨»º´æ¹æÔòºÍÉèÖÃ×î¼Ñʵ¼ùµÈ¡£Í¬Ê± £¬ÎÒÃÇ»¹»áÌṩ´úÂëʾÀý £¬×ÊÖúÄú¸üºÃµØÃ÷È·ºÍʵ¼ùÕâЩ¼¼ÇÉ¡£

¶þ¡¢¾²Ì¬×ÊÔ´ÓÅ»¯

ÉèÖûº´æÓâÆÚʱ¼ä

¾²Ì¬×ÊÔ´ÈçͼƬ¡¢CSSºÍJavaScriptµÈÒ»Ñùƽ³£²»»áƵÈԱ任 £¬Òò´Ë¿ÉÒÔͨ¹ýÉèÖûº´æÓâÆÚʱ¼äÀ´ïÔ̭ЧÀÍÆ÷ѹÁ¦¡£ÔÚNginxÉèÖÃÎļþÖÐ £¬¿ÉÒÔʹÓÃexpiresÖ¸ÁîÉèÖþ²Ì¬×ÊÔ´µÄ»º´æÓâÆÚʱ¼ä¡£ÒÔÏÂÊÇÒ»¸öʾÀý£º

location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {

expires 7d;

µÇ¼ºó¸´ÖÆ

}

ÉÏÊöÉèÖÃÌåÏÖ¹ØÓÚÆ¥ÅäÖ¸¶¨ºó׺µÄ¾²Ì¬×ÊÔ´ £¬½«Æ仺´æ7Ìì¡£ÕâÑù £¬ÔÚ7ÌìÄÚ»á¼ûÏàͬ×ÊԴʱ £¬ä¯ÀÀÆ÷»áÖ±½Ó´ÓÍâµØ»º´æÖлñÈ¡ £¬ïÔÌ­Á˶ÔЧÀÍÆ÷µÄÇëÇó¡£

ÆôÓÃgzipѹËõ

ÆôÓÃgzipѹËõ¿ÉÒÔÓÐÓüõС´«ÊäÎļþµÄ¾Þϸ £¬ÌáÉýÒ³Ãæ¼ÓÔØËÙÂÊ¡£ÔÚNginxÉèÖÃÎļþÖÐ £¬¿ÉÒÔʹÓÃgzipÖ¸ÁîÀ´¿ªÆôgzipѹËõ¡£ÒÔÏÂÊÇÒ»¸öʾÀý£º

gzip on;

gzip_min_length 1k;

gzip_comp_level 2;

gzip_types text/plain text/css application/javascript;

gzip_vary on;

ÉÏÊöÉèÖÃÌåÏÖÆôÓÃgzipѹËõ £¬²¢ÉèÖÃÁËһЩÏà¹Ø²ÎÊý £¬ÈçѹËõ¼¶±ð¡¢ÎļþÀàÐ͵È¡£

Èý¡¢¶¯Ì¬ÄÚÈÝ»º´æ

É趨»º´æ¹æÔò

¹ØÓÚ¶¯Ì¬ÌìÉúµÄÄÚÈÝ £¬ÎÒÃÇ¿ÉÒÔʹÓÃNginxµÄproxy_cacheÖ¸ÁîÀ´ÊµÏÖ»º´æ¡£ÏÂÃæÊÇÒ»¸öÉèÖÃÊðÀí»º´æµÄʾÀý£º

http {

proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m;

server {
    location / {
        proxy_cache my_cache;
        proxy_cache_valid 200 10m;
        proxy_cache_valid 404 1m;
        proxy_pass http://backend;
    }
}

µÇ¼ºó¸´ÖÆ

}

ÉÏÊöÉèÖÃÖÐ £¬ÎÒÃÇͨ¹ýproxy_cache_pathÀ´½ç˵»º´æ·¾¶ºÍÏà¹Ø²ÎÊý¡£ÔÚserver¿éÖÐ £¬Í¨¹ýproxy_cacheÖ¸ÁÆô»º´æ £¬²¢Ê¹ÓÃproxy_cache_validÀ´ÉèÖûº´æÓÐÓÃʱ¼ä¡£

ÉèÖÃ×î¼Ñʵ¼ù

³ýÁËÉÏÊö»ù±¾µÄÉèÖà £¬»¹¿ÉÒÔƾ֤ÏÖʵÐèÇóÉèÖøü¶àµÄNginx»º´æÏà¹ØÖ¸Áî £¬ÒÔʵÏÖ¸üºÃµÄÐÔÄܺÍÓû§ÌåÑé¡£ÒÔÏÂÊÇһЩ×î¼Ñʵ¼ùµÄʾÀý£º

http {

...

proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
proxy_cache_lock on;
proxy_cache_lock_age 5s;
proxy_cache_lock_timeout 10s;
proxy_cache_revalidate on;
proxy_cache_background_update on;
proxy_cache_bypass $cookie_nocache $arg_nocache$arg_comment;

...

µÇ¼ºó¸´ÖÆ

}

ÉÏÊöÉèÖÃÖÐ £¬ÎÒÃÇʹÓÃÁËproxy_cache_use_staleÀ´ÉèÖûº´æÓâÆÚºóµÄÐÐΪ £¬proxy_cache_lockÀ´ÆôÓûº´æËø¶¨¹¦Ð§ £¬proxy_cache_revalidateÀ´ÖØÐÂÑéÖ¤»º´æ¹¤¾ßµÄÓÐÓÃÐԵȵÈ¡£

ËÄ¡¢×ܽá

±¾ÎÄÏêϸÏÈÈÝÁËÔõÑùʹÓÃNginx¾ÙÐо²Ì¬×ÊÔ´ÓÅ»¯ºÍ¶¯Ì¬ÄÚÈÝ»º´æµÄ¼¼ÇÉ¡£Í¨¹ýÉèÖûº´æÓâÆÚʱ¼ä¡¢ÆôÓÃgzipѹËõ¡¢É趨»º´æ¹æÔòºÍÉèÖÃ×î¼Ñʵ¼ù £¬ÎÒÃÇ¿ÉÒÔÌáÉýЧÀÍÆ÷ÐÔÄܺÍÓû§ÌåÑé¡£

ÔÚʵ¼ùÀú³ÌÖÐ £¬ÎÒÃÇ»¹Í¨¹ý´úÂëʾÀýÀ´ÑÝʾÁËÏêϸµÄÉèÖÃÒªÁìºÍʹÓü¼ÇÉ¡£Ï£Íûͨ¹ý±¾ÎĵÄÏÈÈÝ £¬ÄúÄܸüºÃµØÃ÷È·ºÍʹÓÃNginx¾ÙÐÐЧÀÍÆ÷ÓÅ»¯»ººÍ´æ¼¼ÇÉ £¬ÎªÓû§Ìṩ¸ü¿ì¡¢¸üÎȹ̵ÄwebЧÀÍ¡£

ÒÔÉϾÍÊÇNginx´î½¨Ð§ÀÍÆ÷µÄ¾²Ì¬×ÊÔ´ÓÅ»¯ºÍ¶¯Ì¬ÄÚÈÝ»º´æ¼¼ÇÉÏê½âµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ