Application Framework Reference

App Server Utilities API

set_cache_level()

The set_cache_level() function sets the HTTP caching headers to a preset configuration.

Synopsis

results = set_cache_level( cache_level , response )

Parameters

cache_level

String

Cache level literal:
never = Explicitly defeat client-side caching.
etag = Apply an ETag header by MD5 hashing the body.
always = Set max caching.

response

String

Deprecated

Return Value

Undefined

Raises

ValueError

'Unrecognized cache level: %s' % cache_level

Example

from splunk.appserver.mrsparkle.lib import util

def renderExample():
    try:
        pageContent = '<p>Sample Content</p>'
    except Exception, e:
        pageContent = '<p class="moduleException"></p>'

    if cherrypy.response.headers.get('Cache-Control') == None:
        return util.set_cache_level('etag', pageContent)
    return pageContent
 

See Also

@set_cache_level()