Catalyst-Plugin-PageCache

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    Known Issues when choosing a cache backend.

WARNINGS
    PageCache should be placed at the end of your plugin list.

    You should only use the page cache on pages which have NO user-specific
    or customized content. Also, be careful if caching a page which may
    forward to another controller. For example, if you cache a page behind a
    login screen, the logged-in version may be cached and served to
    unauthenticated users.

    Note that pages that result from POST requests will never be cached.

PERFORMANCE
    On my Athlon XP 1800+ Linux server, a cached page is served in 0.008
    seconds when using the HTTP::Daemon server and any of the Cache plugins.

CONFIGURATION
    Configuration is optional. You may define the following configuration
    values:

        expires => $seconds

    This will set the default expiration time for all page caches. If you do
    not specify this, expiration defaults to 300 seconds (5 minutes).

        cache_headers => 1

    Enable this value if you need your cached responses to include custom
    HTTP headers set by your application. This may be necessary if you
    operate behind an edge cache such as Akamai. This option is disabled by
    default.

        set_http_headers => 1

    Enabling this value will cause Catalyst to set the correct HTTP headers
    to allow browsers and proxy servers to cache your page. This will
    further reduce the load on your server. The headers are set in such a
    way that the browser/proxy cache will expire at the same time as your
    cache. The Last-Modified header will be preserved if you have already
    specified it. This option is disabled by default.

        auto_cache => [
            $uri,
        ]

    To automatically cache certain pages, or all pages, you can specify
    auto-cache URIs as an array reference. Any controller within your
    application that matches one of the auto_cache URIs will be cached using
    the default expiration time. URIs may be specified as absolute: '/list'
    or as a regex: '/view/.*'

        disable_index => 1

    In order to support the "clear_cached_page" method, PageCache keeps an
    index of all cached pages. If you don't intend to use
    "clear_cached_page", you may enable this config option to avoid the
    overhead of creating and updating the cache index. This option is
    disabled by default.

        busy_lock => 10

    On a high traffic site where page re-generation may take many seconds, a
    common problem encountered is the "dog-pile" effect, where many
    concurrent connections all hit a page where the cache has expired and
    all perform the same expensive operation to rebuild the cache. To
    prevent this situation, you can set the busy_lock option to the maximum
    number of seconds any of your pages can be expected to take to rebuild
    the cache. Then, when the cache expires, the first request will rebuild
    the cache while also extending the expiration time by the number of
    seconds specified, allowing other requests that arrive before the cache
    has been rebuilt to use the previously cached page. This option is
    disabled by default.

        debug => 1

    This will print additional debugging information to the Catalyst log.
    You will need to have -Debug enabled to see these messages. You can also
    specify an optional config parameter auto_check_user. If this option is
    enabled, automatic caching is disabled for logged in users.

        cache_hook => 'cache_hook_method'

    Calls a method on the application that is expected to return a true or
    false. This method is called before dispatch, and before finalize so you
    can short circuit the pagecache behavior. As an example, if you want to
    disable PageCache while running under debug mode:

        package MyApp;
        
    ...
        
    sub cache_hook_method { return shift->debug; }

    Or, if you want to not cache for certain roles, say "admin":

        sub cache_hook_method {
            my ( $c ) = @_;
            return !$c->check_user_roles('admin');
        }

    Note that this is called BEFORE auto_check_user, so you have more
    flexibility to determine what to do for not logged in users.

    To override the generation of page keys:

        __PACKAGE__->config(
            'Plugin::PageCache' => {
                key_maker => sub {
                    my $c = shift;
                    return $c->req->base . '/' . $c->req->path;
                }
            }
        );

METHODS
  cache_page
    Call cache_page in any controller method you wish to be cached.

        $c->cache_page( $expire );

    The page will be cached for $expire seconds. Every user who visits the
    URI(s) referenced by that controller will receive the page directly from
    cache. Your controller will not be processed again until the cache
    expires. You can set this value to as low as 60 seconds if you have
    heavy traffic to greatly improve site performance.



( run in 2.723 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )