[Catalyst-commits] r8476 - in trunk/Catalyst-Plugin-PageCache: .
lib/Catalyst/Plugin t t/lib/TestApp/C
andyg at dev.catalyst.perl.org
andyg at dev.catalyst.perl.org
Mon Sep 29 22:51:18 BST 2008
Author: andyg
Date: 2008-09-29 22:51:18 +0100 (Mon, 29 Sep 2008)
New Revision: 8476
Modified:
trunk/Catalyst-Plugin-PageCache/Changes
trunk/Catalyst-Plugin-PageCache/lib/Catalyst/Plugin/PageCache.pm
trunk/Catalyst-Plugin-PageCache/t/07set_http_headers.t
trunk/Catalyst-Plugin-PageCache/t/lib/TestApp/C/Cache.pm
Log:
Patch from Chris Alef to cache HTTP headers set by the app, this may need to become a configurable option
Modified: trunk/Catalyst-Plugin-PageCache/Changes
===================================================================
--- trunk/Catalyst-Plugin-PageCache/Changes 2008-09-29 17:59:35 UTC (rev 8475)
+++ trunk/Catalyst-Plugin-PageCache/Changes 2008-09-29 21:51:18 UTC (rev 8476)
@@ -1,8 +1,12 @@
Revision history for Perl extension Catalyst::Plugin::PageCache
+0.20
+ - Cache HTTP headers to enable proper functionality behind edge
+ caches such as Akamai. (Chris Alef)
+
0.19 2008-08-22 13:00:00
- - Change config namespace to $c->config->{'Plugin::PageCache'}, old namespace will
- still continue to work.
+ - Change config namespace to $c->config->{'Plugin::PageCache'}, old
+ namespace will still continue to work.
- key_maker method, allows custom cache keys to be used. (Martin Ellison)
0.18 2008-04-25 11:30:00
Modified: trunk/Catalyst-Plugin-PageCache/lib/Catalyst/Plugin/PageCache.pm
===================================================================
--- trunk/Catalyst-Plugin-PageCache/lib/Catalyst/Plugin/PageCache.pm 2008-09-29 17:59:35 UTC (rev 8475)
+++ trunk/Catalyst-Plugin-PageCache/lib/Catalyst/Plugin/PageCache.pm 2008-09-29 21:51:18 UTC (rev 8476)
@@ -4,7 +4,7 @@
use base qw/Class::Accessor::Fast/;
use NEXT;
-our $VERSION = '0.19';
+our $VERSION = '0.20';
# Do we need to cache the current page?
__PACKAGE__->mk_accessors('_cache_page');
@@ -167,6 +167,12 @@
sub _set_page_cache_headers {
my ( $c, $data ) = @_;
+ for my $header_key ( keys %{ $data->{headers} || {} } ) {
+ $c->res->headers->header(
+ $header_key => $data->{headers}->{$header_key}
+ );
+ }
+
return unless $c->config->{'Plugin::PageCache'}->{set_http_headers};
if ( exists $data->{expires} ) {
@@ -258,6 +264,10 @@
|| $c->res->headers->last_modified
|| $now,
expire_time => $now + $options->{cache_seconds},
+ headers => {
+ map { $_ => $c->res->headers->header($_) }
+ $c->res->headers->header_field_names
+ },
};
$data->{expires} = $options->{expires} if exists $options->{expires};
Modified: trunk/Catalyst-Plugin-PageCache/t/07set_http_headers.t
===================================================================
--- trunk/Catalyst-Plugin-PageCache/t/07set_http_headers.t 2008-09-29 17:59:35 UTC (rev 8475)
+++ trunk/Catalyst-Plugin-PageCache/t/07set_http_headers.t 2008-09-29 21:51:18 UTC (rev 8476)
@@ -12,7 +12,7 @@
eval "use Catalyst::Plugin::Cache::FileCache";
plan $@
? ( skip_all => 'needs Catalyst::Plugin::Cache::FileCache for testing' )
- : ( tests => 7 );
+ : ( tests => 11 );
}
# remove previous cache
@@ -37,5 +37,8 @@
cmp_ok( $res->headers->last_modified, '>=', $cache_time, 'last-modified header matches correct time' );
cmp_ok( $res->headers->expires, '>=', $cache_time + 300, 'expires header matches correct time' );
-
-
+#check that extension headers are cached and returned
+ok( $res = request('http://localhost/cache/cache_extension_header/10'), 'request ok' );
+is( $res->headers->header('X-Bogus-Extension'), 'True', 'Bogus header returned');
+ok( $res = request('http://localhost/cache/cache_extension_header/10'), 'request ok' );
+is( $res->headers->header('X-Bogus-Extension'), 'True', 'Bogus header returned from cache');
Modified: trunk/Catalyst-Plugin-PageCache/t/lib/TestApp/C/Cache.pm
===================================================================
--- trunk/Catalyst-Plugin-PageCache/t/lib/TestApp/C/Cache.pm 2008-09-29 17:59:35 UTC (rev 8475)
+++ trunk/Catalyst-Plugin-PageCache/t/lib/TestApp/C/Cache.pm 2008-09-29 21:51:18 UTC (rev 8476)
@@ -31,6 +31,13 @@
$c->forward( 'auto_count' );
}
+sub cache_extension_header : Local {
+ my ( $self, $c, $expires ) = @_;
+ $c->cache_page( $expires );
+ $c->res->headers->header('X-Bogus-Extension' => 'True');
+ $c->res->output( 'ok' );
+}
+
sub clear_cache : Local {
my ( $self, $c ) = @_;
More information about the Catalyst-commits
mailing list