Re: Announce: LWPx-UserAgent-Cached
[email protected] (Mark Gardner) Thu, 12 Feb 2015 15:52:26 -0500
| Newsgroups | perl.libwww |
|---|---|
| Message-ID | <CAMnMuOEgMVcym1Y9zT0Zgyh7B4Sd6hDku2Qp0s561_8faX2EQA@mail.gmail.com> |
--001a1134e0ba5894a4050eea4d23 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, Feb 12, 2015 at 3:24 PM, Nigel Horne <[email protected]> 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=E2=80=A6 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! --001a1134e0ba5894a4050eea4d23 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">On Thu, Feb 12, 2015 at 3:24 PM, Nigel Horne <span dir=3D"= ltr"><<a href=3D"mailto:[email protected]" target=3D"_blank">njh@bandsm= an.co.uk</a>></span> wrote:<br><div class=3D"gmail_extra"><div class=3D"= gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;b= order-left:1px #ccc solid;padding-left:1ex"><span class=3D""><blockquote cl= ass=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;p= adding-left:1ex">I've just released LWPx-UserAgent-Cached to CPAN and w= ould appreciate<br> feedback.<br></blockquote></span></blockquote><blockquote class=3D"gmail_qu= ote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-co= lor:rgb(204,204,204);border-left-style:solid;padding-left:1ex">=C2=A0</bloc= kquote><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-= left:1px #ccc solid;padding-left:1ex"><span class=3D""><blockquote class=3D= "gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding= -left:1ex"> </blockquote></span> Good idea.=C2=A0 How does it compare against using HTTP::Cache::Transparent= with LWP::UserAgent?<span class=3D"HOEnZb"><font color=3D"#888888"><br></f= ont></span></blockquote><div>=C2=A0</div></div>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 l= ifetime of cached responses, or conceivably add logic that looks at the HTT= P headers like HTTP::Cache::Transparent does. (In fact that's a really = good idea, I think I will add that as a default.)</div><div class=3D"gmail_= extra"><br></div><div class=3D"gmail_extra">This also means that you can us= e other storage methods such as those provided by CHI's various drivers= , e.g.: in-memory, file, memory-mapped files, memcached, DBI, BerkeleyDB, R= edis=E2=80=A6</div><div class=3D"gmail_extra"><br></div><div class=3D"gmail= _extra">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::simpl= e_request, which means that all your UAs get caching whether you want it or= not, all using the same cache in the filesystem.</div><div class=3D"gmail_= extra"><br></div><div class=3D"gmail_extra">Hope this helps!</div><div clas= s=3D"gmail_extra"><br></div></div> --001a1134e0ba5894a4050eea4d23--