catalystのキャッシュ

出力をキャッシュする Catalyst::Plugin::PageCache

Catalyst::Plugin::PageCache

    use Catalyst;
    MyApp->setup( qw/Cache::FileCache PageCache/ );

    MyApp->config->{page_cache} = {
        expires => 300,
        set_http_headers => 1,
        auto_cache => [
            '/view/.*',
            '/list',
        ],
        debug => 1,
    };

    # in a controller method
    $c->cache_page( '3600' );

    $c->clear_cached_page( '/list' );


    # Expire at a specific time
    $c->cache_page( $datetime_object );


    # Fine control
    $c->cache_page(
        last_modified   => $last_modified,
        cache_seconds   => 24 * 60 * 60,    # once a day
        expires         => 300,             # allow client caching
    );

※環境によってparamに日本語文字あると無視される場合がある

Caught exception in engine "Wide character in subroutine entry at /usr/local/lib/perl5/site_perl/5.8.8/Cache/FileBackend.pm line 201."

入力テンプレートをキャッシュする

Template-Toolkit Caching and Compiling Options

package MyApp::View::TT;

use strict;
use base 'Catalyst::View::TT';

__PACKAGE__->config(
  TEMPLATE_EXTENSION => '.tt',
  CACHE_SIZE => 64,
  COMPILE_EXT => '.ttc',
  COMPILE_DIR => '/tmp/ttc',
  INCLUDE_PATH => '/home/abw/templates:/usr/share/templates',
);