NAME
Mojolicious::Plugin::Cache::Action - Action caching plugin
VERSION
version 0.0015
SYNOPSIS
Mojolicious:
$self->plugin('cache-action');
Mojolicious::Lite:
plugin 'cache-action';
DESCRIPTION
This plugin caches responses of mojolicious applications. It works by caching the entire output of controller action for every request. Action caching internally uses the before_dispatch hook to serve the response from cache by skipping the entire controller body. Uncached responses are cached in an after_dispatch hook.
The cache is named according to the current host and path. So, the cache will differentiate between an identical page that is accessed from tucker.myplace.com/user/2 and from caboose.myplace.com/user/2 Different representation of the same resource such as tucker.myplace.com/book/list and tucker.myplace.com/book/list.json are considered as separate requests and so are cached separately.
Cache backends
This plugin uses CHI for caching responses. So, all the various cache backends and customization options of CHI are supported. By default, this plugin uses the Memory cache backend. Various other backends
are also available through CHI.
Options
- actions
-
actions => [qw/action1 action2 ....] #Mojolicious::Lite plugin cache-action => { actions => [qw/user show/]}; #Mojolicious $self->plugin('cache-action' => { actions => [qw/user show/]}); By default, all actions with successful GET requests will be cached
- options
-
options => \%options All CHI module options are recognized #Mojolicious lite using memcache plugin cache-action => { options => { driver => 'Memcached', servers => [ "10.0.0.15:11211", "10.0.0.15:11212" ] } } #Mojolicious lite using file based storage plugin cache-action => { options => { driver => 'File', root_dir => '/path/to/cache' } } #Mojolicious using file based storage $self->plugin('cache-action' => { options => { driver => 'File', root_dir => '/path/to/cache' } });
AUTHOR
Siddhartha Basu <biosidd@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 by Siddhartha Basu.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.