line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::StaticCache; |
2
|
1
|
|
|
1
|
|
532
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub register { |
7
|
5
|
|
|
5
|
1
|
16209
|
my ($self, $app, $conf) = @_; |
8
|
|
|
|
|
|
|
|
9
|
5
|
|
100
|
|
|
25
|
$conf->{even_in_dev} ||= 0; |
10
|
5
|
|
100
|
|
|
25
|
$conf->{max_age} ||= 2592000; |
11
|
5
|
|
66
|
|
|
28
|
$conf->{cache_control} ||= "max-age=$conf->{max_age}, must-revalidate"; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$app->hook(after_static => sub { |
14
|
15
|
|
|
15
|
|
27187
|
my $c = shift; |
15
|
15
|
100
|
66
|
|
|
43
|
if ($app->mode eq 'production' || $conf->{even_in_dev}) { |
16
|
10
|
|
|
|
|
86
|
$c->res->headers->cache_control($conf->{cache_control}); |
17
|
|
|
|
|
|
|
} |
18
|
5
|
|
|
|
|
38
|
}); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
1; |
22
|
|
|
|
|
|
|
__END__ |