line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::ActionRole::NotCacheableHeaders; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
24561
|
$Catalyst::ActionRole::NotCacheableHeaders::VERSION = '0.02'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: Set no cache headers for actions |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
10
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
8
|
1
|
|
|
1
|
|
341
|
use Moose::Role; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use HTTP::Date qw(time2str); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
after 'execute' => sub { |
12
|
|
|
|
|
|
|
my $self = shift; |
13
|
|
|
|
|
|
|
my ($controller, $c, @args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
if ( exists $c->action->attributes->{NotCacheable} ) { |
16
|
|
|
|
|
|
|
$c->response->header( |
17
|
|
|
|
|
|
|
'Expires' => 'Thu, 01 Jan 1970 00:00:00 GMT', |
18
|
|
|
|
|
|
|
'Pragma' => 'no-cache', |
19
|
|
|
|
|
|
|
'Cache-Control' => 'no-cache', |
20
|
|
|
|
|
|
|
'Last-Modified' => time2str( time ), |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
no Moose::Role; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; # End of Catalyst::ActionRole::NotCacheableHeaders |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__END__ |
32
|
|
|
|
|
|
|
=pod |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=encoding utf-8 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Catalyst::ActionRole::NotCacheableHeaders - Set no cache headers for actions |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 VERSION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
version 0.02 |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 SYNOPSIS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
package MyApp::Controller::Foo; |
47
|
|
|
|
|
|
|
use Moose; |
48
|
|
|
|
|
|
|
use namespace::autoclean; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
BEGIN { extends 'Catalyst::Controller::ActionRole' } |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__PACKAGE__->config( |
53
|
|
|
|
|
|
|
action_roles => [qw( NotCacheableHeaders )], |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub dont_cache_me : Local NotCacheable { ... } |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 DESCRIPTION |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Provides a ActionRole to set HTTP headers instructing proxies and browsers to |
61
|
|
|
|
|
|
|
not cache the response. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Pragma: no-cache |
64
|
|
|
|
|
|
|
Cache-Control: no-cache |
65
|
|
|
|
|
|
|
Expires: Thu, 01 Jan 1970 00:00:00 GMT |
66
|
|
|
|
|
|
|
Last-Modified: %current time% |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Please note that if any of above headers were already set they will be |
69
|
|
|
|
|
|
|
overwritten. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 SEE ALSO |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Take a look at L<Catalyst::ActionRole::ExpiresHeader> if you want to set the |
74
|
|
|
|
|
|
|
C<Expires> header only. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 AUTHOR |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Alex J. G. BurzyÅski <ajgb@cpan.org> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Alex J. G. BurzyÅski <ajgb@cpan.org>. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
85
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
88
|
|
|
|
|
|
|
|