尊龙凯时人生就是搏

ÔõÑùʹÓÃNginx¾ÙÐж¯Ì¬ÄÚÈÝ»º´æ

ÔõÑùʹÓÃnginx¾ÙÐж¯Ì¬ÄÚÈÝ»º´æ

NginxÊÇÒ»¿î¸ßÐÔÄܵÄwebЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷ £¬ÆÕ±éÓÃÓÚ¹¹½¨¸ßÐÔÄܵÄÍøÕ¾ºÍÓ¦ÓóÌÐò¡£³ýÁË×÷ΪЧÀÍÆ÷ £¬Nginx»¹¿ÉÒÔ×÷Ϊ»º´æЧÀÍÆ÷À´»º´æ¾²Ì¬ºÍ¶¯Ì¬ÄÚÈÝ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃNginxÀ´»º´æ¶¯Ì¬ÄÚÈÝ £¬ÌáÉýÍøÕ¾ÐÔÄܺÍÓû§ÌåÑé¡£

NginxʹÓÃproxy_cacheÄ £¿éÀ´ÊµÏÖ»º´æ¹¦Ð§¡£ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄʾÀýÉèÖÃÎļþ£º

http {
  proxy_cache_path /path/to/cache keys_zone=my_cache:10m;

  server {
    listen 80;
    server_name example.com;

    location / {
      proxy_pass http://backend;
      proxy_cache my_cache;
      proxy_cache_key $scheme$host$request_uri;
      proxy_cache_valid 200 302 10m;
      proxy_cache_valid 404 1m;
    }
  }

  upstream backend {
    server backend.example.com;
  }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄÉèÖÃÎļþÖÐ £¬ÎÒÃǽç˵ÁËÒ»¸ö»º´æĿ¼/path/to/cache £¬²¢¸øËü·ÖÅÉÁËÒ»¸öÃûΪmy_cacheµÄkeys_zone £¬ÕâÑùNginx¾Í¿ÉÒÔ½«»º´æÄÚÈÝÉúÑĵ½¸ÃĿ¼ÖС£È»ºó £¬ÎÒÃÇÔÚserver¿éÖеÄlocationÖпªÆôÁËÊðÀíģʽ £¬²¢½«ÇëÇóת·¢¸øÁ˺ó¶ËЧÀÍÆ÷backend.example.com¡£

ÔÚproxy_cacheÏà¹ØµÄÉèÖÃÖÐ £¬ÎÒÃÇʹÓÃÁËproxy_cache_keyÖ¸ÁîÀ´½ç˵»º´æµÄkey £¬ÕâÀïʹÓÃÁËÇëÇóµÄscheme¡¢hostºÍrequest_uriÀ´×öΪ»º´æµÄkey¡£ÕâÑù¾Í¿ÉÒÔÈ·±£ÏàͬµÄÇëÇó»á±»»º´æÆðÀ´ £¬×èÖ¹ÏàͬµÄÇëÇó¶à´ÎÏòºó¶ËЧÀÍÆ÷·¢ËÍ¡£

ÎÒÃÇ»¹Ê¹ÓÃÁËproxy_cache_validÖ¸ÁîÀ´½ç˵ÁË»º´æµÄÓÐÓÃʱ¼ä¡£¹ØÓÚ·µ»ØÂëΪ200ºÍ302µÄÏìÓ¦ £¬ÎÒÃÇÉèÖÃÁËÓÐÓÃʱ¼äΪ10·ÖÖÓ £»¹ØÓÚ·µ»ØÂëΪ404µÄÏìÓ¦ £¬ÉèÖÃÁËÓÐÓÃʱ¼äΪ1·ÖÖÓ¡£ÕâÑù¾Í¿ÉÒÔƾ֤²î±ðµÄ·µ»ØÂëÀ´ÉèÖòî±ðµÄ»º´æʱ¼ä¡£

ÉèÖÃÍê±Ïºó £¬ÉúÑÄÎļþ²¢ÖØмÓÔØNginxµÄÉèÖ᣽ÓÏÂÀ´ £¬µ±ÓÐÇëÇóµÖ´ïʱ £¬Nginx»áÊ×Ïȼì²éÊÇ·ñÓлº´æ £¬ÈôÊÇÓÐ £¬¾ÍÖ±½Ó·µ»Ø»º´æÄÚÈÝ £¬ÈôÊÇûÓÐ £¬Ôò½«ÇëÇóת·¢¸øºó¶ËЧÀÍÆ÷²¢½«ÏìÓ¦ÉúÑĵ½»º´æÖС£

ÖµµÃ×¢ÖصÄÊÇ £¬NginxµÄ»º´æÊÇ»ùÓÚÎļþµÄ £¬ÕâÒâζ׏ØÓÚ¶¯Ì¬ÄÚÈݵĻº´æ £¬Í¨³ £»áÉúÑÄΪ¾²Ì¬Îļþ¡£Òò´Ë £¬ÈôÊǶ¯Ì¬ÄÚÈÝƵÈÔת±ä £¬»òÕßÐèҪƾ֤Óû§µÄÌض¨ÐÅÏ¢À´·µ»ØÄÚÈÝ £¬ÐèҪעÖØ»º´æµÄ¸üÐÂÕ½ÂÔ¡£

ͨ¹ýʹÓÃNginx¾ÙÐж¯Ì¬ÄÚÈÝ»º´æ £¬¿ÉÒÔ´ó´óÌáÉýÍøÕ¾µÄÐÔÄܺÍÓû§ÌåÑé¡£µ±»º´æÖÀÖÐʱ £¬¿ÉÒÔ×èÖ¹Öظ´´¦ÀíÇëÇó £¬¼õÇáºó¶ËЧÀÍÆ÷µÄ¸ºÔØ £»Í¬Ê± £¬ÓÉÓÚ¾²Ì¬ÎļþµÄ´«ÊäËÙÂʸü¿ì £¬Ò²¿ÉÒÔËõ¶ÌÒ³Ãæ¼ÓÔØʱ¼ä £¬ÌáÉýÓû§µÄ»á¼ûÌåÑé¡£

Ï£Íû±¾ÎÄÄܶԸ÷ÈËÏàʶÔõÑùʹÓÃnginx¾ÙÐж¯Ì¬ÄÚÈÝ»º´æÓÐËù×ÊÖú¡£ÈôÓÐÈκÎÒÉÎÊ £¬½Ó´ýÁôÑÔÌÖÂÛ¡£

ÒÔÉϾÍÊÇÔõÑùʹÓÃNginx¾ÙÐж¯Ì¬ÄÚÈÝ»º´æµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

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

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

QR code
sitemap¡¢ÍøÕ¾µØͼ