Skip Menu |

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

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

People
Owner: bobtfish [...] bobtfish.net
Requestors: jmmills [...] cpan.org
Cc:
AdminCc:

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



Subject: C::P::Static::Simple does not support HTTP If-Modified-Since headers
This issue mostly relates to performance of javascript and image heavy applications that would benefit from use of browser caches. Attached is a patch that would be a (proposed) solution to the problem with the additional feature of allowing the developer to switch on/off (via Plugin config) the If-Modified-Since support when under debug for the catalyst application.
Subject: add-if-modified-since.patch
--- lib/Catalyst/Plugin/Static/Simple.pm.orig 2008-07-28 20:34:19.000000000 -0700 +++ lib/Catalyst/Plugin/Static/Simple.pm 2008-07-28 22:34:44.000000000 -0700 @@ -176,6 +176,20 @@ my $type = $c->_ext_to_type( $full_path ); my $stat = stat $full_path; + # Added support for If-Modified-Since header so our browsers can use their oh-so nifty caches + # This is a rip-off of the If-Modfied-Since support in Catalyst::Plugin::Static with a twist for debugging + # - jmills + if ($c->req->headers->header('If-Modified-Since')) { + my $no_cache = $c->config->{static}->{no_cache_on_debug} || 0; + if ($c->req->headers->if_modified_since == $stat->mtime) { + unless ($c->debug && $no_cache) { + $c->res->status(304); + $c->res->headers->remove_content_headers; + return 1; # true! + } + } + } + $c->res->headers->content_type( $type ); $c->res->headers->content_length( $stat->size ); $c->res->headers->last_modified( $stat->mtime );
Handling of If-Modified-Since and returning a 304 has already been added to the latest version, therefore I'm going to resolve this. However, if you still think the optionally disabling it feature is valuable, then please feel free to reopen, supplying an updated patch?