会话标识符
【Session identifiers】
服务器为新的连接生成唯一ID并将其发送给客户端。客户端和服务器都会保存会话状态。当重新连接时,客户端会发送其保存的会话状态ID,如果服务器也有该ID的状态,则可以同意使用它。否则,服务器将创建一个新的会话。更多信息请参见RFC 2246,第23页和第30页。
【Servers generate a unique ID for new connections and send it to the client. Clients and servers save the session state. When reconnecting, clients send the ID of their saved session state and if the server also has the state for that ID, it can agree to use it. Otherwise, the server will create a new session. See RFC 2246 for more information, page 23 and 30.】
大多数网络浏览器在进行 HTTPS 请求时都支持使用会话标识符进行恢复。
【Resumption using session identifiers is supported by most web browsers when making HTTPS requests.】
对于 Node.js,客户端等待 'session' 事件以获取会话数据,并将该数据提供给后续 tls.connect() 的 session 选项以重用会话。服务器必须实现 'newSession' 和 'resumeSession' 事件的处理程序,以使用会话 ID 作为查找键来保存和恢复会话数据,从而重用会话。为了在负载均衡器或集群工作节点之间重用会话,服务器在其会话处理程序中必须使用共享会话缓存(例如 Redis)。
【For Node.js, clients wait for the 'session' event to get the session data,
and provide the data to the session option of a subsequent tls.connect()
to reuse the session. Servers must
implement handlers for the 'newSession' and 'resumeSession' events
to save and restore the session data using the session ID as the lookup key to
reuse sessions. To reuse sessions across load balancers or cluster workers,
servers must use a shared session cache (such as Redis) in their session
handlers.】