.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.29) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{ . if \nF \{ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "LWP::UserAgent::Role::CHICaching 3pm" .TH LWP::UserAgent::Role::CHICaching 3pm "2016-03-07" "perl v5.22.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" LWP::UserAgent::Role::CHICaching \- A role to allow LWP::UserAgent to cache with CHI .SH "SYNOPSIS" .IX Header "SYNOPSIS" Compose it into a class, e.g. .PP .Vb 6 \& package LWP::UserAgent::MyCacher; \& use Moo; \& extends \*(AqLWP::UserAgent\*(Aq; \& with \*(AqLWP::UserAgent::Role::CHICaching\*(Aq, \& \*(AqLWP::UserAgent::Role::CHICaching::SimpleKeyGen\*(Aq, \& \*(AqLWP::UserAgent::Role::CHICaching::SimpleMungeResponse\*(Aq; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This is a role for creating caching user agents. 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. \s-1HTTP 1.1\s0 defines how to do this. This role makes it possible to use the very flexible \s-1CHI\s0 module to manage such a cache. See LWP::UserAgent::CHICaching for a finished class you can use. .SS "Attributes and Methods" .IX Subsection "Attributes and Methods" .ie n .IP """cache""" 4 .el .IP "\f(CWcache\fR" 4 .IX Item "cache" Used to set the \f(CW\*(C`CHI\*(C'\fR object to be used as cache in the constructor. .ie n .IP """request_uri""" 4 .el .IP "\f(CWrequest_uri\fR" 4 .IX Item "request_uri" The Request-URI of the request. When set, it will clear the \f(CW\*(C`key\*(C'\fR, but should probably be left to be used internally for now. .ie n .IP """request""" 4 .el .IP "\f(CWrequest\fR" 4 .IX Item "request" Wrapping LWP::UserAgent's request method. .ie n .IP """is_shared""" 4 .el .IP "\f(CWis_shared\fR" 4 .IX Item "is_shared" A boolean value to set whether the cache can be shared. The default is that it is. .ie n .IP """heuristics_opts""" 4 .el .IP "\f(CWheuristics_opts\fR" 4 .IX Item "heuristics_opts" A hashref that is passed to the \f(CW\*(C`freshness_lifetime\*(C'\fR method of HTTP::Response, and used to determine the behaviour of the heuristic lifetime. By default, heuristic freshness lifetime is off, only standards-compliant freshness lifetime (i.e. based on the \&\f(CW\*(C`Cache\-Control\*(C'\fR and \f(CW\*(C`Expires\*(C'\fR headers) are used. .SS "Implemented elsewhere" .IX Subsection "Implemented elsewhere" The following are required by this role, but implemented elsewhere. See LWP::UserAgent::Role::CHICaching::SimpleKeyGen and LWP::UserAgent::Role::CHICaching::SimpleMungeResponse for further explanations. .ie n .IP """key"", ""clear_key""" 4 .el .IP "\f(CWkey\fR, \f(CWclear_key\fR" 4 .IX Item "key, clear_key" The key to use for a response. .ie n .IP """cache_vary($response)""" 4 .el .IP "\f(CWcache_vary($response)\fR" 4 .IX Item "cache_vary($response)" A method that returns true if the response may be cached even if it contains a \f(CW\*(C`Vary\*(C'\fR header, false otherwise. The HTTP::Response object will be passed to it as a parameter. .ie n .IP """cache_set($response, $expires_in)""" 4 .el .IP "\f(CWcache_set($response, $expires_in)\fR" 4 .IX Item "cache_set($response, $expires_in)" A method that takes the HTTP::Response from the client and an expires time in seconds and set the actual cache. .ie n .IP """finalize($cached)""" 4 .el .IP "\f(CWfinalize($cached)\fR" 4 .IX Item "finalize($cached)" A method that takes the cached entry as an argument, and will return a HTTP::Response to return to the client. .SH "LIMITATIONS" .IX Header "LIMITATIONS" Will only cache \f(CW\*(C`GET\*(C'\fR requests, and only successful responses. .PP The module does not validate and does not serve stale responses, even when it would be allowed to do so. It nevertheless does most of \&\s-1RFC7234.\s0 .SH "BUGS" .IX Header "BUGS" Please report any bugs to . .SH "AUTHOR" .IX Header "AUTHOR" Kjetil Kjernsmo . .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" It was really nice looking at the code of LWP::UserAgent::WithCache, when I wrote this. .PP Thanks to Matt S. Trout for rewriting this to a Role. .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" This software is copyright (c) 2015, 2016 by Kjetil Kjernsmo. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.