Helpers for dealing with HTTP level caching.
The Cache-Control and Expires header can be defined while adding a handler to the environment:
class MyService(Service):
def run(self):
self.environment.add_handler(...,
cache=CacheConfig(timedelta(minutes=10)),
expires=timedelta(minutes=10))
The details of setting the CacheControl header are documented in the CacheConfig(). The expires argument simply takes a datetime.timedelta() as input and will then generate the Expires header based on the current time and the datetime.timedelta().
Create a CacheConfigT with default values. :param max_age: Number of seconds the response can be cached :type max_age: datetime.timedelta
Parameters: |
|
---|