$ssl_session_reused
The $ssl_session_reused variable indicates whether an SSL session was reused for a connection.
Description
The $ssl_session_reused variable is part of the NGINX functionality that assesses SSL connections. Specifically, it helps determine if an SSL session was reused when handling incoming requests. This optimization can enhance performance by avoiding the overhead of establishing new sessions, leading to faster response times for HTTPS connections. The variable's value is set to either '1' or '0' at the request processing stage, where '1' indicates that the session was successfully reused from a previous connection, while '0' indicates that a new SSL session was created.
This variable is only applicable when SSL/TLS is active in the NGINX server configuration. The handling of SSL sessions is typically configured through directives such as ssl_session_cache and ssl_session_timeout. When reusing sessions, the handshake process is simplified, significantly reducing latency and computational load. Therefore, this feature is especially valuable on servers that handle a significant amount of secure traffic, as successful session reuse can improve throughput and user experience.
To utilize this variable, ensure your NGINX server is compiled with SSL support. Also, verify that the relevant SSL session cache settings are configured correctly to optimize session reuse effectively. Monitoring $ssl_session_reused can provide insights into the efficiency of the SSL setup, which is crucial for maintaining performance in a secure environment.
Config Example
http {
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
server {
listen 443 ssl;
location / {
add_header X-SSL-Session-Reused $ssl_session_reused;
}
}
}Ensure that SSL is enabled in your NGINX configuration; otherwise, the variable will always return '0'.
Remember to configure the SSL session cache properly to see meaningful statistics about session reuse.
Avoid using this variable in inappropriate contexts such as non-SSL configurations.