尊龙凯时人生就是博

ÆÊÎöNginxµÄ·´ÏòÊðÀí»º´æºÍ¶¯Ì¬ÄÚÈÝ»º´æʵÏÖϸ½Ú

ÆÊÎöNginxµÄ·´ÏòÊðÀí»º´æºÍ¶¯Ì¬ÄÚÈÝ»º´æʵÏÖϸ½Ú

NginxÊÇÒ»¿î¸ßÐÔÄܵÄWebЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷ ¡£ÔÚÏÖʵµÄWebÓ¦ÓÃÖÐ £¬ÎªÁËÌá¸ßÍøÕ¾µÄ»á¼ûËÙÂʺÍÐÔÄÜ £¬¾­³£ÐèҪʹÓ÷´ÏòÊðÀí»º´æºÍ¶¯Ì¬ÄÚÈÝ»º´æÀ´¼ÓËÙWebÒ³ÃæµÄ¼ÓÔغÍÏìÓ¦ ¡£±¾ÎĽ«ÏêϸÆÊÎöNginxµÄ·´ÏòÊðÀí»º´æºÍ¶¯Ì¬ÄÚÈÝ»º´æµÄʵÏÖϸ½Ú £¬²¢¸ø³öÏìÓ¦µÄ´úÂëʾÀý ¡£

Ò»¡¢·´ÏòÊðÀí»º´æµÄʵÏÖϸ½Ú

·´ÏòÊðÀí»º´æÊÇÖ¸NginxÔÚ×÷Ϊ·´ÏòÊðÀíЧÀÍÆ÷µÄͬʱ £¬Ò²¿ÉÒÔ½«¿Í»§¶ËÇëÇóµÄÏìӦЧ¹û»º±£´æ×ÔÉíµÄÄÚ´æ»ò´ÅÅÌÉÏ £¬ÒÔ±ãÏ´ÎÇëÇóͬÑùµÄ×ÊԴʱֱ½Ó·µ»Ø»º´æЧ¹û £¬´Ó¶øÌá¸ß»á¼ûËÙÂʺͼõÇáºó¶ËЧÀÍÆ÷µÄѹÁ¦ ¡£

ÆôÓ÷´ÏòÊðÀí»º´æ

Ê×ÏÈÐèÒªÔÚNginxµÄÉèÖÃÎļþÖÐÆôÓ÷´ÏòÊðÀí»º´æµÄ¹¦Ð§ ¡£ÔÚhttpÄ£¿éÄÚ¿ÉÒÔÌí¼ÓÒÔÏÂÉèÖÃÐÅÏ¢£º

http {
    ...
    proxy_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m use_temp_path=off;

    server {
        ...
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃÖÐ £¬proxy_cache_pathÖ¸¶¨ÁË»º´æµÄ·¾¶ºÍÏà¹Ø²ÎÊý ¡£levels²ÎÊýÖ¸¶¨ÁË»º´æµÄĿ¼½á¹¹ £¬keys_zone²ÎÊýÖ¸¶¨ÁË»º´æµÄÃû³ÆºÍ¾Þϸ £¬max_size²ÎÊýÖ¸¶¨ÁË»º´æµÄ×î´óÈÝÁ¿ £¬inactive²ÎÊýÖ¸¶¨ÁË»º´æµÄÓâÆÚʱ¼ä £¬use_temp_path²ÎÊýÖ¸¶¨ÁËÊÇ·ñʹÓÃÔÝʱ·¾¶¾ÙÐлº´æ ¡£ÔÚÉÏÊöÉèÖÃÖÐ £¬ÎÒÃÇʹÓÃÁËÃûΪmy_cacheµÄ»º´æ ¡£

ÉèÖ÷´ÏòÊðÀí»º´æµÄ¹æÔò

ÔÚNginxµÄÉèÖÃÎļþÖÐ £¬¿ÉÒÔͨ¹ýlocationÖ¸ÁîÀ´ÉèÖ÷´ÏòÊðÀí»º´æµÄ¹æÔò ¡£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔ½«Ö¸¶¨µÄURL·¾¶¾ÙÐлº´æ £¬ÏêϸµÄÉèÖÃÈçÏÂËùʾ£º

server {
    ...
    
    location /cached {
        proxy_cache my_cache;
        proxy_cache_valid 200 304 10m;
        proxy_cache_use_stale error timeout invalid_header http_500;
        proxy_cache_background_update on;
        proxy_pass http://backend_server;
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃÖÐ £¬proxy_cacheÖ¸¶¨ÁËʹÓÃÄĸö»º´æ £¬proxy_cache_validÖ¸¶¨ÁË»º´æµÄÓÐÓÃÆÚ £¬proxy_cache_use_staleÖ¸¶¨Á˵±»º´æÓâÆÚʱÊÇ·ñʹÓþɵĻº´æ¾ÙÐÐÏìÓ¦ £¬proxy_cache_background_updateÖ¸¶¨ÁËÊÇ·ñºǫ́¸üлº´æ £¬proxy_passÖ¸¶¨Á˺ó¶ËЧÀÍÆ÷µÄµØµã ¡£

ɨ³ý»º´æ

ÓÐʱ¼äÐèÒªÊÖ¶¯É¨³ý»º´æ £¬¿ÉÒÔʹÓÃproxy_cache_purgeÄ£¿éÀ´ÊµÏÖ ¡£ÔÚNginxµÄÉèÖÃÎļþÖÐ £¬¿ÉÒÔÌí¼ÓÒÔÏÂÉèÖãº

location /purge {
    bproxy_cache_purge my_cache "$scheme$request_method$host$request_uri";
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃÖÐ £¬proxy_cache_purgeÖ¸¶¨ÁËɨ³ý»º´æµÄÏÂÁî £¬²¢×ª´ïÁË»º´æµÄÃû³ÆºÍÇëÇóµÄURI ¡£

¶þ¡¢¶¯Ì¬ÄÚÈÝ»º´æµÄʵÏÖϸ½Ú

¶¯Ì¬ÄÚÈÝ»º´æÊÇÖ¸NginxÔÚ·´ÏòÊðÀíЧÀÍÆ÷µÄͬʱ £¬Ò²¿ÉÒÔ½«¶¯Ì¬ÌìÉúµÄÄÚÈݾÙÐлº´æ £¬ÒÔ¼õÇáºó¶ËЧÀÍÆ÷µÄ¸ºÔغÍÌá¸ßÏìÓ¦ËÙÂÊ ¡£

ÆôÓö¯Ì¬ÄÚÈÝ»º´æ

Ê×ÏÈÐèÒªÔÚNginxµÄÉèÖÃÎļþÖÐÆôÓö¯Ì¬ÄÚÈÝ»º´æµÄ¹¦Ð§ ¡£ÔÚhttpÄ£¿éÄÚ¿ÉÒÔÌí¼ÓÒÔÏÂÉèÖÃÐÅÏ¢£º

http {
    ...
    fastcgi_cache_path /path/to/cache levels=1:2 keys_zone=my_cache:10m max_size=10g inactive=60m use_temp_path=off;

    server {
        ...
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃÖÐ £¬fastcgi_cache_pathÖ¸¶¨ÁË»º´æµÄ·¾¶ºÍÏà¹Ø²ÎÊý £¬Óë·´ÏòÊðÀí»º´æµÄÉèÖÃÀàËÆ ¡£Í¬Ñù £¬ÎÒÃÇʹÓÃÁËÃûΪmy_cacheµÄ»º´æ ¡£

ÉèÖö¯Ì¬ÄÚÈÝ»º´æµÄ¹æÔò

ÔÚNginxµÄÉèÖÃÎļþÖÐ £¬Ò²¿ÉÒÔͨ¹ýlocationÖ¸ÁîÀ´ÉèÖö¯Ì¬ÄÚÈÝ»º´æµÄ¹æÔò ¡£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔ½«Ö¸¶¨µÄURL·¾¶µÄ¶¯Ì¬ÄÚÈݾÙÐлº´æ £¬ÏêϸµÄÉèÖÃÈçÏÂËùʾ£º

server {
    ...
    
    location /dynamic {
        fastcgi_cache my_cache;
        fastcgi_cache_valid 200 10m;
        fastcgi_cache_methods GET HEAD;
        fastcgi_cache_use_stale error timeout invalid_header http_500;
        fastcgi_cache_lock on;
        fastcgi_cache_lock_timeout 5s;
        fastcgi_pass backend_server;
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃÖÐ £¬fastcgi_cacheÖ¸¶¨ÁËʹÓÃÄĸö»º´æ £¬fastcgi_cache_validÖ¸¶¨ÁË»º´æµÄÓÐÓÃÆÚ £¬fastcgi_cache_methodsÖ¸¶¨ÁËÄÄЩHTTPÒªÌå»á±»»º´æ £¬fastcgi_cache_use_staleÖ¸¶¨Á˵±»º´æÓâÆÚʱÊÇ·ñʹÓþɵĻº´æ¾ÙÐÐÏìÓ¦ £¬fastcgi_cache_lockÖ¸¶¨ÁËÊÇ·ñÆôÓûº´æËøºÍËøµÄ³¬Ê±Ê±¼ä £¬fastcgi_passÖ¸¶¨Á˺ó¶ËЧÀÍÆ÷µÄµØµã ¡£

ɨ³ý»º´æ

ͬÑùµØ £¬ÓÐʱ¼äÐèÒªÊÖ¶¯É¨³ý»º´æ £¬¿ÉÒÔʹÓÃfastcgi_cache_purgeÄ£¿éÀ´ÊµÏÖ ¡£ÔÚNginxµÄÉèÖÃÎļþÖÐ £¬¿ÉÒÔÌí¼ÓÒÔÏÂÉèÖãº

location /purge {
    fastcgi_cache_purge my_cache "$scheme$request_method$host$request_uri";
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÉèÖÃÖÐ £¬fastcgi_cache_purgeÖ¸¶¨ÁËɨ³ý»º´æµÄÏÂÁî £¬²¢×ª´ïÁË»º´æµÄÃû³ÆºÍÇëÇóµÄURI ¡£

×ÛÉÏËùÊö £¬±¾ÎÄÏêϸÆÊÎöÁËNginxµÄ·´ÏòÊðÀí»º´æºÍ¶¯Ì¬ÄÚÈÝ»º´æµÄʵÏÖϸ½Ú £¬²¢¸ø³öÁËÏìÓ¦µÄ´úÂëʾÀý ¡£Í¨¹ýºÏÀíÉèÖúÍʹÓÃNginxµÄ»º´æ¹¦Ð§ £¬¿ÉÒÔÏÔÖøÌáÉýWebÓ¦ÓõÄÐÔÄܺÍÓû§ÌåÑé ¡£

ÒÔÉϾÍÊÇÆÊÎöNginxµÄ·´ÏòÊðÀí»º´æºÍ¶¯Ì¬ÄÚÈÝ»º´æʵÏÖϸ½ÚµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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