def set_cache_headers(f):
 @functools.wraps(f)
 def wrapper(*args, **kwargs):
  ttl = 31536000
  expires = datetime.datetime.fromtimestamp((int(time.time()) + ttl))
  expires = expires.strftime('%a, %d %b %Y %H:%M:%S GMT')
  headers = {'Cache-Control': 'public, max-age={0}'.format(ttl), 'Expires': expires, 'Last-Modified': 'Thu, 01 Jan 1970 00:00:00 GMT'}
  if ('If-Modified-Since' in flask.request.headers):
   return flask.Response(status=304, headers=headers)
  kwargs['headers'] = headers
  return f(*args, **kwargs)
 return wrapper

def set_cache_headers ( f ) : @ functools . wraps ( f ) def wrapper ( * args , ** kwargs ) : ttl = 31536000 expires = datetime . datetime . fromtimestamp ( ( int ( time . time ( ) ) + ttl ) ) expires = expires . strftime ( '%a, %d %b %Y %H:%M:%S GMT' ) headers = { 'Cache-Control' : 'public, max-age={0}' . format ( ttl ) , 'Expires' : expires , 'Last-Modified' : 'Thu, 01 Jan 1970 00:00:00 GMT' } if ( 'If-Modified-Since' in flask . request . headers ) : return flask . Response ( status = 304 , headers = headers ) kwargs [ 'headers' ] = headers return f ( * args , ** kwargs ) return wrapper
returns http headers suitable for caching .