Skip to main content

patch_cache_control

Patch the Cache-Control header by adding all keyword arguments to it. The transformation is as follows:

* All keyword parameter names are turned to lowercase, and underscores
are converted to hyphens.
* If the value of a parameter is True (exactly True, not just a
true value), only the parameter name is added to the header.
* All other parameters are added with their value, after applying
str() to it.
def patch_cache_control(
response: HttpResponse,
**kwargs: Any
) - > null

Patch the Cache-Control header by adding all keyword arguments to it. The transformation is as follows:

  • All keyword parameter names are turned to lowercase, and underscores are converted to hyphens.
  • If the value of a parameter is True (exactly True, not just a true value), only the parameter name is added to the header.
  • All other parameters are added with their value, after applying str() to it.

Parameters

NameTypeDescription
responseHttpResponseThe HTTP response object whose 'Cache-Control' header will be modified.
**kwargsAnyDirectives to add to the Cache-Control header, where keys are directive names (underscores converted to hyphens) and values are directive arguments.

Returns

TypeDescription
nullThe function modifies the response object in-place and does not return a value.