预览加载中,请您耐心等待几秒...
1/6
2/6
3/6
4/6
5/6
6/6

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

Nginxcache基本指令整理 本文主要针对nginx的几个主要cache指令做一个简单的整理,另外部分指令做了实际测试, 本文具体包括如下指令: proxy_cache,proxy_cache_bypass,proxy_cache_key,proxy_cache_lock,proxy_cache_lock_timeou t,proxy_cache_min_uses,proxy_cache_path,proxy_cache_use_stale,proxy_cache_valid,proxy_no_ cache 更多相关内容:http://www.iigrowing.cn/nginx 1.proxy_cache syntax:proxy_cachezone|off; default:proxy_cacheoff; context:http,server,location 定义一块共享内存区域用来进行缓存。相同名称的缓存区域可以在多个地方使用。Off 参数关闭从前一个级别配置中继承下来的缓存设置 Nginx官方原文如下: Definesasharedmemoryzoneusedforcaching.Thesamezonecanbeusedinseveralplaces. Theoffparameterdisablescachinginheritedfromthepreviousconfigurationlevel. 2.proxy_cache_bypass yntax:proxy_cache_bypassstring...; default:— context:http,server,location 定义一个条件,在这个条件成立后将不会从缓存中获取数据。至少有一个字符串参数不 为空,并且是不等于“0”,则响应不会从缓存中获取。 Nginx官方原文如下: Definesconditionsunderwhichtheresponsewillnotbetakenfromacache.Ifatleastone valueofthestringparametersisnotemptyandisnotequalto“0”thentheresponsewillnotbe takenfromthecache: proxy_cache_bypass$cookie_nocache$arg_nocache$arg_comment; proxy_cache_bypass$http_pragma$http_authorization; Canbeusedalongwiththeproxy_no_cachedirective. 3.proxy_cache_key syntax:proxy_cache_keystring; default:proxy_cache_key$scheme$proxy_host$request_uri; context:http,server,location 给缓存数据定义一个键,例如 proxy_cache_key"$host$request_uri$cookie_user"; 默认情况下,该指令的值的字符串 proxy_cache_key$scheme$proxy_host$uri$is_args$args; Nginx官方原文如下: Definesakeyforcaching,forexample proxy_cache_key"$host$request_uri$cookie_user"; Bydefault,thedirective’svalueisclosetothestring proxy_cache_key$scheme$proxy_host$uri$is_args$args; 4.proxy_cache_lock syntax:proxy_cache_lockon|off; default:proxy_cache_lockoff; context:http,server,location Thisdirectiveappearedinversion1.1.12. 当指令被指定时,根据proxy_cache_key指令确定的若干个或得出相同响应元素若干个 请求仅仅有一个能被传递给后端的代理服务器(最终传递给应用服务器)去生成响应内容, 生成后响应内容添加到cache中,其他请求从cache中获取数据。其他请求将等待cache中 有内容出现或者等待超时为止。 Nginx官方原文如下: Whenenabled,onlyonerequestatatimewillbeallowedtopopulateanewcacheelement identifiedaccordingtotheproxy_cach