[Catalyst] PageCache and SubRequest

Kyoko Shikamata shikamata at shoeisha.co.jp
Tue Nov 20 10:39:22 GMT 2007


Hello All,

I have a trouble about PageCache(Cache::FileCache) and SubRequest .  
The part using SubRequest of the page cannot be cached often .

- Controller :
use Catalyst qw/SubRequest Cache::FileCache PageCache/;

__PACKAGE__->config->{page_cache} = {
    expires => 300,
    set_http_headers => 1,
    debug => 1,
};
__PACKAGE__->config->{cache}->{storage} = '/tmp';

sub index : Local  {
 my ( $self, $c ) = @_;
 $c->cache_page( 300 );
 # action 
 $c->stash->{template} = 'index.tt'
 $c->forward("My::View::TT");
}

sub test : Path('/parts/test')  {
 my ( $self, $c ) = @_;
 $c->response->body('Test');
}

- TT (index.tt):
<html>
<body>
Hello
[%c.subreq('/parts/test')%]
</body>
</html>

I hope that the page including 'Hello' and 'Test' are cached.
But, often I cannot see 'Test'  in the cached page.
The behavior often happens.

Best regards,
---
Kyoko Shikamata





More information about the Catalyst mailing list