def patch_response_headers(response, cache_timeout=None):
 if (cache_timeout is None):
  cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
 now = datetime.datetime.utcnow()
 if (not response.has_header('ETag')):
  response['ETag'] = md5.new(response.content).hexdigest()
 if (not response.has_header('Last-Modified')):
  response['Last-Modified'] = now.strftime('%a, %d %b %Y %H:%M:%S GMT')
 if (not response.has_header('Expires')):
  expires = (now + datetime.timedelta(0, cache_timeout))
  response['Expires'] = expires.strftime('%a, %d %b %Y %H:%M:%S GMT')
 if (cache_timeout < 0):
  cache_timeout = 0
 patch_cache_control(response, max_age=cache_timeout)

def patch_response_headers ( response , cache_timeout = None ) : if ( cache_timeout is None ) : cache_timeout = settings . CACHE_MIDDLEWARE_SECONDS now = datetime . datetime . utcnow ( ) if ( not response . has_header ( 'ETag' ) ) : response [ 'ETag' ] = md5 . new ( response . content ) . hexdigest ( ) if ( not response . has_header ( 'Last-Modified' ) ) : response [ 'Last-Modified' ] = now . strftime ( '%a, %d %b %Y %H:%M:%S GMT' ) if ( not response . has_header ( 'Expires' ) ) : expires = ( now + datetime . timedelta ( 0 , cache_timeout ) ) response [ 'Expires' ] = expires . strftime ( '%a, %d %b %Y %H:%M:%S GMT' ) if ( cache_timeout < 0 ) : cache_timeout = 0 patch_cache_control ( response , max_age = cache_timeout )
adds some useful headers to the given httpresponse object: etag .