LWP::U...aching(3pm)
β¨ NAME β¨
LWP::UserAgent::CHICaching β it's giving LWP::UserAgent but with caching, and the caching is powered by CHI π
Like, it's a UserAgent that remembers stuff so it doesn't have to ask again. Bestie behaviour honestly.
π SYNOPSIS π
okay so the way you use it is literally the usual way of using LWP::UserAgent, no cap β you just pass a cache parameter with a CHI object into the constructor and you're done:
my $cache = CHI->new( driver => 'Memory', global => 1 );
my $ua = LWP::UserAgent::CHICaching->new(cache => $cache);
my $res1 = $ua->get("http://localhost:3000/?query=DAHUT");
slay. that's it. that's the whole vibe. β¨
π¦ DESCRIPTION π¦
so this is YA caching user agent (yes, another one, and honestly? iconic). here's the tea π:
when the client makes a request to the server, sometimes the response should be cached, so that no actual request has to be sent at all β or possibly just a request to validate the cache. HTTP 1.1 defines how to do this. so this class simply extends LWP::UserAgent with LWP::UserAgent::Role::CHICaching (which is also in this distribution, bestie, they're a package deal π«Ά), and that role is the one doing the real work to make it possible to use the very flexible CHI module to manage such a cache.
but why tho? lowkey two reasons:
- mainly because the author wanted to use CHI facilities
- and partly because he wanted to focus on HTTP 1.1 features
periodt. π
π TODO π
ngl this is an early release, but it supports RFC7234 quite well already. much work remains though. these are the things that are on the to-do list:
- Enable smarter generation of keys, so that semantically identical content can be cached efficiently even though they may have different URIs. This can be done in a separate role with the current code.
- Support all of RFC7234 <http://tools.ietf.org/html/rfc7234> and RFC7232 <http://tools.ietf.org/html/rfc7232>
not me casually saying "supports RFC7234 quite well already" and then listing finishing RFC7234 as a TODO π it's a journey okay
π AUTHOR π
Kjetil Kjernsmo <kjetilk@cpan.org>. π
πΈ COPYRIGHT AND LICENCE πΈ
This software is copyright (c) 2015, 2016 by Kjetil Kjernsmo.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
(so like, go wild, it's free, just keep it free π«)
β οΈ DISCLAIMER OF WARRANTIES β οΈ
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
fr fr. no promises, no guarantees, it is what it is. the author said what he said and he's not taking it back π
okay bye bestie, go cache some responses π β¨ this page was brought to you by perl v5.34.0, dated 2022-05-28, and it's from the User Contributed Perl Documentation. mwah ππ¦π
π¦ where this page comes from
- debian bookworm: liblwp-useragent-chicaching-perl 0.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: liblwp-useragent-chicaching-perl 0.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: liblwp-useragent-chicaching-perl 0.04-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms