Skip to content

Instantly share code, notes, and snippets.

@nottrobin
Created February 18, 2016 10:29
Show Gist options
  • Select an option

  • Save nottrobin/689048cb1baedc84d440 to your computer and use it in GitHub Desktop.

Select an option

Save nottrobin/689048cb1baedc84d440 to your computer and use it in GitHub Desktop.
How to add headers in your custom TemplateView
class OurTemplateView(TemplateView):
def render_to_response(self, context, **response_kwargs):
# Get response from parent TemplateView class
response = super(CmsTemplateFinder, self).render_to_response(
context, **response_kwargs
)
# Add Cache-Control and Expires headers
patch_response_headers(response, cache_timeout=300)
# Return response
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment