Package cherrypy :: Package lib :: Module caching
[hide private]
[frames] | no frames]

Module caching

source code

Classes [hide private]
  MemoryCache
Functions [hide private]
 
get(invalid_methods=('POST', 'PUT', 'DELETE'), **kwargs)
Try to obtain cached output.
source code
 
tee_output() source code
 
expires(secs=0, force=False)
Tool for influencing cache mechanisms using the 'Expires' header.
source code
Variables [hide private]
  __package__ = 'cherrypy.lib'
Function Details [hide private]

get(invalid_methods=('POST', 'PUT', 'DELETE'), **kwargs)

source code 
Try to obtain cached output. If fresh enough, raise HTTPError(304).

If POST, PUT, or DELETE:
    * invalidates (deletes) any cached response for this resource
    * sets request.cached = False
    * sets request.cacheable = False

else if a cached copy exists:
    * sets request.cached = True
    * sets request.cacheable = False
    * sets response.headers to the cached values
    * checks the cached Last-Modified response header against the
        current If-(Un)Modified-Since request headers; raises 304
        if necessary.
    * sets response.status and response.body to the cached values
    * returns True

otherwise:
    * sets request.cached = False
    * sets request.cacheable = True
    * returns False

expires(secs=0, force=False)

source code 
Tool for influencing cache mechanisms using the 'Expires' header.

'secs' must be either an int or a datetime.timedelta, and indicates the
number of seconds between response.time and when the response should
expire. The 'Expires' header will be set to (response.time + secs).

If 'secs' is zero, the 'Expires' header is set one year in the past, and
the following "cache prevention" headers are also set:
   'Pragma': 'no-cache'
   'Cache-Control': 'no-cache, must-revalidate'

If 'force' is False (the default), the following headers are checked:
'Etag', 'Last-Modified', 'Age', 'Expires'. If any are already present,
none of the above response headers are set.