# ``twisted`.`web`.`client`.`HostnameCachingHTTPSPolicy``

class documentation

`class HostnameCachingHTTPSPolicy: (source)`

Implements interfaces: `twisted.web.iweb.IPolicyForHTTPS`

View In Hierarchy

IPolicyForHTTPS that wraps a `IPolicyForHTTPS` and caches the created `IOpenSSLClientConnectionCreator`.

This policy will cache up to `cacheSize` `client connection creators` for reuse in subsequent requests to the same hostname.

Present Since
Twisted 19.2.0

Method | `__init__` |
Method | `creatorForNetloc` | Create a `client connection creator` for a given network location and cache it for future use.
Instance Variable | `_cache` | A cache associating hostnames to their `client connection creators`.
Instance Variable | `_cacheSize` | See `cacheSize` parameter of `__init__`.
Instance Variable | `_policyForHTTPS` | See `policyforHTTPS` parameter of `__init__`.

def __init__(self, policyforHTTPS, cacheSize=20): (source)

Parameters
policyforHTTPS:`IPolicyForHTTPS` | The IPolicyForHTTPS to wrap.
cacheSize:`int` | The maximum size of the hostname cache.

def creatorForNetloc(self, hostname, port): (source)
from `twisted.web.iweb.IPolicyForHTTPS`
Create a `client connection creator` for a given network location and cache it for future use.

Parameters
hostname:`bytes` | The hostname part of the URI.
port:`int` | The port part of the URI.
Returns
`client connection creator` | a connection creator with appropriate verification restrictions set

_cache: `collections.OrderedDict` = (source)
A cache associating hostnames to their `client connection creators`.
_cacheSize = (source)
See `cacheSize` parameter of `__init__`.
_policyForHTTPS = (source)
See `policyforHTTPS` parameter of `__init__`.