Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Announce: LWPx-UserAgent-Cached

1 view
Skip to first unread message

Mark Gardner

unread,
Feb 12, 2015, 12:30:02 AM2/12/15
to lib...@perl.org
I've just released LWPx-UserAgent-Cached to CPAN and would appreciate
feedback. It's a(nother) subclass of LWP::UserAgent that uses CHI and
Sereal to cache HTTP GET requests, inspired largely by
WWW::Mechanize::Cached but without all the Mech baggage.

https://metacpan.org/release/LWPx-UserAgent-Cached

Please feel free to fork or log issues on GitHub, or just contact me.

https://github.com/mjgardner/LWPx-UserAgent-Cached

Thanks!

--
Mark Gardner $ <m...@phoenixtrap.com>

Mark Gardner

unread,
Feb 12, 2015, 4:00:03 PM2/12/15
to lib...@perl.org
On Thu, Feb 12, 2015 at 3:24 PM, Nigel Horne <n...@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!

0 new messages