plugin/forward: init ClientSessionCache in tls.Config
* plugin/forward: init ClientSessionCache in tls.Config
- ClientSessionCache may speed up a TLS handshake in upcoming connections
to the same TLS server
* add comment
package forward
import (
+ "crypto/tls"
"errors"
"fmt"
"strconv"
@@ -117,6 +118,11 @@ func parseStanza(c *caddy.Controller) (*Forward, error) {
if f.tlsServerName != "" {
f.tlsConfig.ServerName = f.tlsServerName
}
+
+ // Initialize ClientSessionCache in tls.Config. This may speed up a TLS handshake
+ // in upcoming connections to the same TLS server.
+ f.tlsConfig.ClientSessionCache = tls.NewLRUClientSessionCache(len(f.proxies))
+
for i := range f.proxies {
// Only set this for proxies that need it.
if transports[i] == transport.TLS {
