Plack::Middleware::StaticShared - concat some static files to one resource
use Plack::Builder; use WebService::Google::Closure; builder { enable "StaticShared", cache => Cache::Memcached::Fast->new(servers => [qw/192.168.0.11:11211/]), base => './static/', binds => [ { prefix => '/.shared.js', content_type => 'text/javascript; charset=utf8', filter => sub { WebService::Google::Closure->new(js_code => $_)->compile->code; } }, { prefix => '/.shared.css', content_type => 'text/css; charset=utf8', } ]; verifier => sub { my ($version, $prefix) = @_; $version =~ /v\d/ }, $app; };
And concatnated resources are provided as like following:
/.shared.js:v1:/js/foolib.js,/js/barlib.js,/js/app.js => concat following: ./static/js/foolib.js, ./static/js/barlib.js, ./static/js/app.js
Plack::Middleware::StaticShared provides resource end point which concat some static files to one resource for reducing http requests.
A cache object for caching concatnated resource content.
Base directory which concatnating resource located in.
Definition of concatnated resources.
A subroutine for verifying version string to avoid attacking of cache flooding.
cho45
Plack::Middleware Plack::Builder
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Plack::Middleware::StaticShared, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::StaticShared
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::StaticShared
For more information on module installation, please visit the detailed CPAN module installation guide.