Plack::Middleware::NeverExpire - set expiration headers far in the future
# in app.psgi use Plack::Builder; builder { enable_if { $_[0]{'PATH_INFO'} =~ m!^/static/! } 'NeverExpire'; $app; };
This middleware adds headers to a response that allow proxies and browsers to cache them for an effectively unlimited time. It is meant to be used in conjunction with the Conditional middleware.
This middleware provides some functions for general use. They are not exported.
imf_fixdate
This takes an epoch time and returns it as a timestamp formatted according to RFC 9110 section 5.6.7.
inject_headers
This takes a PSGI response array and adds the caching headers to it if the status is 200. It returns nothing.
Plack::Middleware::Expires
For most requests you want either immediate expiry with conditional GET, or indefinite caching, or on high-load websites maybe a very short expiry duration for certain URIs (on the order of minutes or seconds, just to keep them from getting hammered): fine-grained control is rarely needed. I wanted a really trivial middleware for when it's not, so I wrote NeverExpire.
GET
But when you need it, Expires will give you the precise control over expiry durations that NeverExpire doesn't.
Aristotle Pagaltzis <pagaltzis@gmx.de>
This software is copyright (c) 2015 by Aristotle Pagaltzis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Plack::Middleware::NeverExpire, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::NeverExpire
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::NeverExpire
For more information on module installation, please visit the detailed CPAN module installation guide.