(key=None)
Use the HTTP Entity Tag cache for Browser side caching

    If a "If-None-Match" header is found, and equivilant to ``key``,
    then a ``304`` HTTP message will be returned with the ETag to tell
    the browser that it should use its current cache of the page.

    Otherwise, the ETag header will be added to the response headers.

    Suggested use is within a Controller Action like so:

    .. code-block:: python

        import pylons

        class YourController(BaseController):
            def index(self):
                etag_cache(key=1)
                return render('/splash.mako')

    .. note::
        This works because etag_cache will raise an HTTPNotModified
        exception if the ETag received matches the key provided.
Use the HTTP Entity Tag cache for Browser side caching
Use the HTTP Entity Tag cache for Browser side caching
def etag_cache(key=None):
    """Use the HTTP Entity Tag cache for Browser side caching

    If a "If-None-Match" header is found, and equivilant to ``key``,
    then a ``304`` HTTP message will be returned with the ETag to tell
    the browser that it should use its current cache of the page.

    Otherwise, the ETag header will be added to the response headers.

    Suggested use is within a Controller Action like so:

    .. code-block:: python

        import pylons

        class YourController(BaseController):
            def index(self):
                etag_cache(key=1)
                return render('/splash.mako')

    .. note::
        This works because etag_cache will raise an HTTPNotModified
        exception if the ETag received matches the key provided.

    """
    if_none_matches = IF_NONE_MATCH.findall(
        pylons.request.environ.get('HTTP_IF_NONE_MATCH', ''))
    response = pylons.response._current_obj()
    response.headers['ETag'] = '"%s"' % key
    if str(key) in if_none_matches:
        log.debug("ETag match, returning 304 HTTP Not Modified Response")
        response.headers.pop('Content-Type', None)
        response.headers.pop('Cache-Control', None)
        response.headers.pop('Pragma', None)
        raise status_map[304]()
    else:
        log.debug("ETag didn't match, returning response object")
def etag_cache ( key = None ) : if_none_matches = IF_NONE_MATCH . findall ( pylons . request . environ . get ( 'HTTP_IF_NONE_MATCH' , '' ) ) response = pylons . response . _current_obj ( ) response . headers [ 'ETag' ] = '"%s"' % key if str ( key ) in if_none_matches : log . debug ( "ETag match, returning 304 HTTP Not Modified Response" ) response . headers . pop ( 'Content-Type' , None ) response . headers . pop ( 'Cache-Control' , None ) response . headers . pop ( 'Pragma' , None ) raise status_map [ 304 ] ( ) else : log . debug ( "ETag didn't match, returning response object" )