1Send an ETag header, and honour the If-None-Match request header
2
3diff -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
4--- Catalyst-Plugin-Static-Simple-0.30-orig/lib/Catalyst/Plugin/Static/Simple.pm 2012-05-04 18:49:30.000000000 +0200
5+++ Catalyst-Plugin-Static-Simple-0.30/lib/Catalyst/Plugin/Static/Simple.pm 2013-02-25 22:57:18.667150181 +0100
6@@ -187,16 +187,27 @@
7 my $type = $c->_ext_to_type( $full_path );
8 my $stat = stat $full_path;
9
10- $c->res->headers->content_type( $type );
11- $c->res->headers->content_length( $stat->size );
12- $c->res->headers->last_modified( $stat->mtime );
13 # Tell Firefox & friends its OK to cache, even over SSL:
14- $c->res->headers->header('Cache-control' => 'public');
15+ #$c->res->headers->header('Cache-control' => 'public');
16+
17+ $c->res->headers->last_modified( $stat->mtime );
18 # Optionally, set a fixed expiry time:
19 if ($config->{expires}) {
20 $c->res->headers->expires(time() + $config->{expires});
21 }
22
23+ if ($config->{send_etag}) {
24+ my $etag = '"' . $stat->mtime . '-' . $stat->ino . '-'. $stat->size . '"';
25+ $c->res->headers->header('ETag' => $etag);
26+ if (($c->req->header('If-None-Match') // "") eq $etag) {
27+ $c->res->status(304);
28+ return 1;
29+ }
30+ }
31+
32+ $c->res->headers->content_type( $type );
33+ $c->res->headers->content_length( $stat->size );
34+
35 my $fh = IO::File->new( $full_path, 'r' );
36 if ( defined $fh ) {
37 binmode $fh;