LWP::U...aching(3pm)

πŸ“¦
version 0.04 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble

✨ 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:

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>. πŸ’–


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