about summary refs log tree commit diff
path: root/pkgs/development/perl-modules
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-02-25 18:12:00 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-02-25 18:17:16 +0100
commitf6460facd682a5aee2973981aa8af7abfb27d2f2 (patch)
tree6400cae44b88472540fec65c0da20815543cdda0 /pkgs/development/perl-modules
parentd1e614ad73ac0a1fe2b3b2183bbb3bfcc938ad11 (diff)
Catalyst::Plugin::Static::Simple: Add ETag support
This should keep browsers from caching Hydra's static files for too
long.
Diffstat (limited to 'pkgs/development/perl-modules')
-rw-r--r--pkgs/development/perl-modules/catalyst-plugin-static-simple-etag.patch29
1 files changed, 29 insertions, 0 deletions
diff --git a/pkgs/development/perl-modules/catalyst-plugin-static-simple-etag.patch b/pkgs/development/perl-modules/catalyst-plugin-static-simple-etag.patch
new file mode 100644
index 0000000000000..6433cf296630a
--- /dev/null
+++ b/pkgs/development/perl-modules/catalyst-plugin-static-simple-etag.patch
@@ -0,0 +1,29 @@
+Send an ETag header, and honour the If-None-Match request header
+
+diff -ru -x '*~' Catalyst-Plugin-Static-Simple-0.30-orig/lib/Catalyst/Plugin/Static/Simple.pm Catalyst-Plugin-Static-Simple-0.30/lib/Catalyst/Plugin/Static/Simple.pm
+--- Catalyst-Plugin-Static-Simple-0.30-orig/lib/Catalyst/Plugin/Static/Simple.pm	2012-05-04 18:49:30.000000000 +0200
++++ Catalyst-Plugin-Static-Simple-0.30/lib/Catalyst/Plugin/Static/Simple.pm	2013-02-25 18:05:08.466813337 +0100
+@@ -187,11 +187,21 @@
+     my $type      = $c->_ext_to_type( $full_path );
+     my $stat      = stat $full_path;
+ 
++    # Tell Firefox & friends its OK to cache, even over SSL:
++    #$c->res->headers->header('Cache-control' => 'public');
++
++    if ($config->{send_etag}) {
++        my $etag = '"' . $stat->mtime . '-' . $stat->ino . '-'. $stat->size . '"';
++        $c->res->headers->header('ETag' => $etag);
++        if (($c->req->header('If-None-Match') // "") eq $etag) {
++            $c->res->status(304);
++            return 1;
++        }
++    }
++
+     $c->res->headers->content_type( $type );
+     $c->res->headers->content_length( $stat->size );
+     $c->res->headers->last_modified( $stat->mtime );
+-    # Tell Firefox & friends its OK to cache, even over SSL:
+-    $c->res->headers->header('Cache-control' => 'public');
+     # Optionally, set a fixed expiry time:
+     if ($config->{expires}) {
+         $c->res->headers->expires(time() + $config->{expires});