3 messages in com.googlegroups.pylons-discussRe: Anti-cacheing headers in Pylons
FromSent OnAttachments
voltron26 Sep 2007 13:46 
James Gardner26 Sep 2007 15:39 
voltron26 Sep 2007 16:22 
Subject:Re: Anti-cacheing headers in Pylons
From:voltron (nhyt@public.gmane.org)
Date:09/26/2007 04:22:54 PM
List:com.googlegroups.pylons-discuss

Thanks!

On Sep 27, 12:39 am, James Gardner
<ja..@public.gmane.org> wrote:

You can edit your config/middleware.py file so the end of it looks like this:

... javascripts_app = StaticJavascripts()

class NoCache(object): def __init__(self, app): self.app = app def __call__(self, environ, start_response): def sr(status,headers,exc_info=None): headers.append( ( 'Cache-Control', 'no-cache, no-store, must-revalidate' ) ) return start_response(status,headers,exc_info) return self.app(environ, sr)

app = NoCache(app)

app = Cascade([static_app, javascripts_app, app]) return app

If you want to force everything to be refreshed, not just the dynamically generated pages you can wrap the whole app in the NoCache middleware.

Or you can do it from a controller action with:

response.headers['Cache-Control']='no-cache, no-store, must-revalidate'

James

voltron wrote:

How does one generate anti-cacheing headers in Pylons?

Thanks!