Scroll to navigation

LWP::UserAgent::Role::CHICaching::SimpleKeyGen(3pm) User Contributed Perl Documentation LWP::UserAgent::Role::CHICaching::SimpleKeyGen(3pm)

NAME

LWP::UserAgent::Role::CHICaching::SimpleKeyGen - A role for cache keys when caching LWP::UserAgent

SYNOPSIS

See LWP::UserAgent::Role::CHICaching.

DESCRIPTION

LWP::UserAgent::Role::CHICaching is a role for creating caching user agents. There's some complexity around caching different variants of the same resource (e.g. the same thing in different natural languages, different serializations that is considered in Section 4.1 of RFC7234 <http://tools.ietf.org/html/rfc7234#section-4.1> that this role is factored out to address in the dumbest way possible: Just don't cache when the problem arises.

To really solve this problem in a better way, you need to generate a cache key based on not only the URI, but also on the content (e.g. "Content-Language: en"), and so, provide a better implementation of the "key" attribute, and then, you also need to tell the system when it is OK to cache something with a "Vary" header by making the "cache_vary" method smarter. See LWP::UserAgent::Role::CHICaching::VaryNotAsterisk for an example of an alternative.

Attributes and Methods

"key", "clear_key"
The key to use for a response. This role will return the canonical URI of the request as a string, which is a reasonable default.
"cache_vary"
Will never allow a response with a "Vary" header to be cached.

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.

2022-05-28 perl v5.34.0