Django - Setting Headers in your Response

Today I found a interesting part in the Django Docs about set and remove of Headers in responses .

response = HttpResponse()  # Created a HttpResponse
response['Cache-Control'] = 'no-cache'  # Set Cache-Control Header
del response['Cache-Control']  # Remove Cache-Control Header

I know that should be do the web server like Apache but sometimes is it nicer (even recommended) to set in some cases the headers in web app directly, to test the behaviour or to make really sure to get the right headers in the response if you don't have anytime access to the server config's or a lazy sys-admin.

For you interest:

Set and Remove in the Django Docs Content-Disposition example

Comments !