Skip Menu |

This queue is for tickets about the Catalyst-Plugin-Static-Simple CPAN distribution.

Report information
The Basics
Id: 94919
Status: new
Priority: 0/
Queue: Catalyst-Plugin-Static-Simple

People
Owner: Nobody in particular
Requestors: tsibley [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.31
Fixed in: (no value)



Subject: If-Modified-Since
I'd expect a static handler to support If-Modified-Since and status 304 responses out of the box, but this doesn't. Attached is a simple patch to make it do so. Enabling the ConditionalGET middleware has the same effect, but requires the user add an additional bit of configuration. Though at that point, there's not much reason not to just use Plack::App::Static. I don't really care about my patch vs. ConditionalGET, but I think If-Modified-Since should be supported out of the box one way or another.
Subject: 0001-Respond-with-a-304-Not-Modified-if-an-If-Modified-Si.patch
From 1b58f984126a1f74898f7c8a5851232728a03f63 Mon Sep 17 00:00:00 2001 From: Thomas Sibley <trsibley@uw.edu> Date: Mon, 21 Apr 2014 15:01:26 -0700 Subject: [PATCH] Respond with a 304 Not Modified if an If-Modified-Since header matches --- lib/Catalyst/Plugin/Static/Simple.pm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/Catalyst/Plugin/Static/Simple.pm b/lib/Catalyst/Plugin/Static/Simple.pm index 39a8f77..2f0b0d2 100644 --- a/lib/Catalyst/Plugin/Static/Simple.pm +++ b/lib/Catalyst/Plugin/Static/Simple.pm @@ -184,6 +184,13 @@ sub _serve_static { my $type = $c->_ext_to_type( $full_path ); my $stat = stat $full_path; + my $since = $c->req->headers->if_modified_since; + if ($since and $stat->mtime <= $since) { + $c->res->status(304); + $c->res->body(undef); + return; + } + $c->res->headers->content_type( $type ); $c->res->headers->content_length( $stat->size ); $c->res->headers->last_modified( $stat->mtime ); -- 1.8.5