Plack:...xpires(3pm)
β¨ NAME β¨
Plack::Middleware::Expires β literally mod_expires but for plack, bestie π
It's the Perl module Plack::Middleware::Expires, and it's giving "Apache's mod_expires, but make it Plack." π¦
πΈ SYNOPSIS πΈ
use Plack::Builder;
builder {
enable 'Expires',
content_type => qr!^image/!i,
expires => 'access plus 3 months';
$app;
}
π DESCRIPTION π
Plack::Middleware::Expires is Apache's mod_expires for Plack. No cap. π«Ά
This middleware controls the setting of the Expires HTTP header and the max-age directive of the Cache-Control HTTP header in server responses. It's the little glow-up your responses needed so browsers stop re-downloading everything like it's their first day on the internet. π
Note, bestie, read this part: π -Expiresworks only for successful response, π - If anExpiresHTTP header exists already, it will not be overridden by this middleware. It knows better than to fight an existing header. π
π CONFIGURATIONS π
content_type
content_type => qr!^image!,
content_type => 'text/css',
content_type => [ 'text/css', 'application/javascript', qr!^image/! ]
This is the Content-Type header to apply Expires to. Yes, it takes a regex, yes it takes a plain string, yes it takes an arrayref of both β she's flexible like that. β¨
also content_type accept CodeRef π
content_type => sub { my $env = shift; return 1 if $env->{..} }
Expires
Same format as the Apache mod_expires, periodt. π
expires => 'M3600' # last_modified + 1 hour
expires => 'A86400' # access + 1 day
expires => 'modification plus 3 years 3 month 3 day'
expires => 'access plus 3 days'
Like... look at those options. M for last_modified, A for access, or spell the whole thing out like a main character. Either way, iconic. π
π AUTHOR π
Masahiro Nagano <kazeburo {at} gmail.com>
π¦ SEE ALSO π¦
<http://httpd.apache.org/docs/2.2/en/mod/mod_expires.html>
(the og Apache mod_expires docs β go pay respects π)
β LICENSE β
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.34.0 Β· 2022-06-16
k that's the whole page bestie, mwah π β documented by the perl v5.34.0 girlies on 2022-06-16, slay πβ¨
π¦ where this page comes from
- debian bookworm: libplack-middleware-expires-perl 0.06-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libplack-middleware-expires-perl 0.06-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libplack-middleware-expires-perl 0.06-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms