Welcome, guest | Sign In | My Account | Store | Cart

Sometimes you just don't want a page to be cached, ever, by the client's web browser. This recipe tells you how to do that from DTML.

Python, 11 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
From DTML:

<dtml-call "RESPONSE.setHeader('Cache-Control', 'no-cache')">
<dtml-call "RESPONSE.setHeader('Pragma', 'no-cache')">


From python/python script:

def noCache(self, REQUEST):
    REQUEST.RESPONSE.setHeader('Cache-Control', 'no-cache')
    REQUEST.RESPONSE.setHeader('Pragma', 'no-cache')

There are two things done here. The first is to set the "Cache-Control" header. This works on newer browsers. The second is to set the Pragma header. Older browsers use this one. A newer browser will ignore Pragma if Cache-Control is defined.

Created by David Shaw on Fri, 6 Apr 2001 (PSF)
Python recipes (4591)
David Shaw's recipes (1)

Required Modules

  • (none specified)

Other Information and Tasks