def browser_cache(seconds):
    """Decorator for browser cache. Only for webpy
    @browser_cache( seconds ) before GET/POST function.
    """
    import web
    def wrap(f):
        def wrapped_f(*args):
            last_time_str = web.ctx.env.get('HTTP_IF_MODIFIED_SINCE', '')
            last_time = web.net.parsehttpdate(last_time_str)
            now = datetime.datetime.now()
            if last_time and\
                    last_time + datetime.timedelta(seconds = seconds) > now:
                web.notmodified()
            else:
                web.lastmodified(now)
                web.header('Cache-Control', 'max-age='+str(seconds))
            yield f(*args)
        return wrapped_f
    return wrap
def browser_cache ( seconds ) : import web def wrap ( f ) : def wrapped_f ( * args ) : last_time_str = web . ctx . env . get ( 'HTTP_IF_MODIFIED_SINCE' , '' ) last_time = web . net . parsehttpdate ( last_time_str ) now = datetime . datetime . now ( ) if last_time and last_time + datetime . timedelta ( seconds = seconds ) > now : web . notmodified ( ) else : web . lastmodified ( now ) web . header ( 'Cache-Control' , 'max-age=' + str ( seconds ) ) yield f ( * args ) return wrapped_f return wrap
Decorator for browser cache. Only for webpy
    @browser_cache( seconds ) before GET/POST function.