The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojolicious::Plugin::Cache::Page - Page caching plugin

VERSION

version 0.0015

SYNOPSIS

Mojolicious:

 $self->plugin('cache-page');

Mojolicious::Lite:

 plugin 'cache-page';

DESCRIPTION

This plugin caches the entire output of controller action in a HTML file which can be delivered directly by the webserver without even going through the controller at all. The cache will generate files for example user/2/view.html, user/new.html etc which matches the request urls. The webserver picks up the existing file by matching the path otherwise it gets passed to the mojolicious controller.

The cache is named according to path and so the cache will not differentiate between an identical page that is accessed from tucker.myplace.com/user/2/view.html and from caboose.myplace.com/user/2/view.html. This caching system ignores the query parameters. So, for example /users?page=1 will be cached as users.html and so another call to /users?page=2 will retrieve the users.html. The cache is expired by deleting the html file that defered it creation until a new request comes in.

Options

actions
 actions => [qw/action1 action2 ....]

 #Mojolicious::Lite 
 plugin cache-page => { actions => [qw/user show/]}; 

 By default,  all actions with successful GET requests will be cached
cache_directory
  By default, for mojolicious lite application the current working directory is set for
  page caching. For mojolicious application it is set to the B<public> folder. 

  #Mojolicious lite using memcache 
  plugin cache-page => { cache_direcotry => '/home/page_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.