develooper Front page | perl.libwww | Postings from February 2015

Re: Announce: LWPx-UserAgent-Cached

Thread Previous
From:
Mark Gardner
Date:
February 12, 2015 20:52
Subject:
Re: Announce: LWPx-UserAgent-Cached
Message ID:
CAMnMuOEgMVcym1Y9zT0Zgyh7B4Sd6hDku2Qp0s561_8faX2EQA@mail.gmail.com
On Thu, Feb 12, 2015 at 3:24 PM, Nigel Horne <njh@bandsman.co.uk> wrote:

> I've just released LWPx-UserAgent-Cached to CPAN and would appreciate
>> feedback.
>>
>

 Good idea.  How does it compare against using HTTP::Cache::Transparent
> with LWP::UserAgent?
>

LWPx::UserAgent::Cache lets you configure the cache options by using your
own cache object, as long as it has a "get" and "set" method. So you can
tweak the lifetime of cached responses, or conceivably add logic that looks
at the HTTP headers like HTTP::Cache::Transparent does. (In fact that's a
really good idea, I think I will add that as a default.)

This also means that you can use other storage methods such as those
provided by CHI's various drivers, e.g.: in-memory, file, memory-mapped
files, memcached, DBI, BerkeleyDB, Redis…

Lastly, it's a subclass of LWP::UserAgent so you can choose to use it on
one user agent and not on another, or have different options for different
UAs. HTTP::Cache::Transparent monkeypatches LWP::UserAgent::simple_request,
which means that all your UAs get caching whether you want it or not, all
using the same cache in the filesystem.

Hope this helps!

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About