zhasm
5/17/2013 - 6:55 AM

django no cache decorator.

django no cache decorator.

def no_cache():
    def decorator(f):
        def wrapper(*args, **kwargs):
            response = f(*args, **kwargs)
            response['Last-Modified'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime())
            response['Expires'] = 'Wed, 11 Jan 1984 05:00:00 GMT'
            response['Cache-Control'] = 'no-cache, must-revalidate, max-age=0'
            response['Pragma'] = 'no-cache'
            return response
        return wrapper
    return decorator