nginx学习随笔–ssl_session_cache
英文原文:
Syntax: ssl_session_cache off | none | [builtin[:size]] [shared:name:size];
Default: ssl_session_cache none;
Context: http, server
Sets the types and sizes of caches that store session parameters. A cache can be of any of the following types:
off
the use of a session cache is strictly prohibited: nginx explicitly tells a client that sessions may not be reused.
none
the use of a session cache is gently disallowed: nginx tells a client that sessions may be reused, but does not actually store session parameters in the cache.
builtin
a cache built in OpenSSL; used by one worker process only. The cache size is specified in sessions. If size is not given, it is equal to 20480 sessions. Use of the built-in cache can cause memory fragmentation.
shared
a cache shared between all worker processes. The cache size is specified in bytes; one megabyte can store about 4000 sessions. Each shared cache should have an arbitrary name. A cache with the same name can be used in several virtual servers.
Both cache types can be used simultaneously, for example:
ssl_session_cache builtin:1000 shared:SSL:10m;
but using only shared cache without the built-in cache should be more efficient.
中文翻译:
设置存储session参数的缓存的类型和大小。缓存可以是下面任何一种类型:
off
严格禁止使用会话缓存:nginx明确告知客户端会话不可重用。
none
会话缓存是不允许的:nginx告知客户端会话可以重用,但并没有在缓存中存储会话参数。
builtin
在OpenSSL中构建缓存;只能被一个工作进程使用。缓存的大小在会话中指定,如果没有指定大小,默认20480个会话。使用内置缓存会导致内存碎片化。
shared
缓存在所有工作进程之间共享。缓存大小按照字节为单位指定;1MB可以存储4000个会话。每块共享内存都应该起个名字。同一块缓存可以在多个虚拟服务中使用。
两种类型的缓存可以同时使用:
ssl_session_cache builtin:1000 shared:SSL:10m;
但是,单独使用共享缓存会更有效。