Intra
Intra

Reputation: 2109

render_to_response with HTTP response headers

How to use HTTP response headers with Django render_to_response

I want to use Cache-Control but can't tell if it is working. Is the following correct:

render_to_response(templatename, {'Cache-Control':'no-cache'},context_instance=RequestContext(httpreq))

Upvotes: 10

Views: 5345

Answers (1)

Set headers directly on the response object.

https://docs.djangoproject.com/en/dev/ref/request-response/#setting-headers

response = render_to_response(...)
response['Cache-Control'] = 'no-cache'
return response

Upvotes: 16

Related Questions