Skip Menu |

This queue is for tickets about the LWP-UserAgent-Cache-Memcached CPAN distribution.

Report information
The Basics
Id: 45849
Status: new
Priority: 0/
Queue: LWP-UserAgent-Cache-Memcached

People
Owner: Nobody in particular
Requestors: dan [...] humyo.com
Cc:
AdminCc:

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



Subject: LWP::UserAgent::Cache::Memcached fails when content had not changed
Date: Fri, 08 May 2009 14:08:06 +0100
To: bug-LWP-UserAgent-Cache-Memcached [...] rt.cpan.org, cyberlib [...] gmail.com
From: Dan Conlon <dan [...] humyo.com>
Hi, We're using your LWP::UserAgent::Cache::Memcached on our front page at http://www.humyo.com to cache the result of fetching an RSS feed to update the news section. However, when the expires time passes, LWP::UserAgent::Cache::Memcached causes the request to be sent with If-Modified-Since and If-None-Match headers. The server then responds (correctly I think because the content has not changed) with 304 Not Modified and an empty content body. LWP::UserAgent::Cache::Memcached then passes back the empty content body instead of the cached value which is still good. The following patch fixes this and stores the new expires in the cache. Unless I've missed something silly, do you think you could incorporate this into a new release? Thanks, Dan Conlon humyo.com --- a/LWP/UserAgent/Cache/Memcached.pm 2008-04-18 09:21:02.000000000 +0100 +++ b/LWP/UserAgent/Cache/Memcached.pm 2009-05-08 14:02:22.000000000 +0100 @@ -79,8 +79,11 @@ } my $res = $self->SUPER::request(@args); + + $res = HTTP::Response->parse($obj->{as_string}) if $res->code eq HTTP::Status::RC_NOT_MODIFIED; + my $exptime = int($self->{lwp_useragent_cache_memcached_config}->{exptime} || 0); - $self->set_cache($uri, $res, $exptime) if $res->code eq HTTP::Status::RC_OK; + $self->set_cache($uri, $res, $exptime) if $res->code eq HTTP::Status::RC_OK or $res->code eq HTTP::Status::RC_NOT_MODIFIED; return $res; }