[Catalyst] Caching problem?
Brandon Black
blblack at gmail.com
Wed Jan 11 20:51:37 CET 2006
On 1/11/06, Jesse Sheidlower <jester at panix.com> wrote:
> On Wed, Jan 11, 2006 at 11:59:42AM -0500, Andy Grundman wrote:
> > Dr. Jennifer Nussbaum wrote:
> > > hi,
> > >
> > >I have a Catalyst application that does the usual database thingies. I
> > >just learned that when database info changes, the pages arent getting
> > >updated because theyre being cached, so if someone goes to
> > >www.mysite.com/catalog/view/242, they get the same content even if
> > >things have changed. Users can "reload" in the browser and get the
> > >right content.
> > >
> > >Whats the easiest way that this doesnt happen?
> >
> > You probably want to set a Cache-Control header. This is a good page to
> > read about the topic: http://www.mnot.net/cache_docs/
> >
> > A simple no-cache setup in Catalyst would look like this, in your end
> > method:
> >
> > $c->res->headers->header( 'Cache-Control' => 'no-cache, max-age=0' );
>
> Apart from the more extended headers that others have talked about, I've
> also found it sensible to turn this into something like:
>
> $c->res->headers->header( 'Cache-Control' => 'no-cache, max-age=0' )
> unless $c->req->path =~ /static/;
>
What I do is put the no-cache headers inside the "auto" action in my
main application module, like:
sub auto : Private {
my ( $self, $c ) = @_;
$c->res->no_cache;
[....]
}
This way they get set on all content generated by a Controller, but
they don't get set on other content (like that served by
Static::Simple, for example).
-- Brandon
More information about the Catalyst
mailing list