Skip to main content

patch_response_headers

Add HTTP caching headers to the given HttpResponse: Expires and Cache-Control.

Each header is only added if it isn't already set.

cache_timeout is in seconds. The CACHE_MIDDLEWARE_SECONDS setting is used
by default.
def patch_response_headers(
response: HttpResponse,
cache_timeout: int = None
) - > null

Add HTTP caching headers to the given HttpResponse: Expires and Cache-Control. Each header is only added if it isn't already set.

Parameters

NameTypeDescription
responseHttpResponseThe HTTP response object to which the caching headers will be applied.
cache_timeoutint = NoneThe time in seconds for which the response should be cached; defaults to the CACHE_MIDDLEWARE_SECONDS setting.

Returns

TypeDescription
nullNone; the response object is modified in-place.