NAME HTTP::Tiny::Patch::Cache - Cache HTTP::Tiny responses VERSION This document describes version 0.004 of HTTP::Tiny::Patch::Cache (from Perl distribution HTTP-Tiny-Patch-Cache), released on 2019-04-14. SYNOPSIS From Perl: use HTTP::Tiny::Patch::Cache # -max_age => 7200, # optional, sets max age, can also be set via environment variables ; my $res = HTTP::Tiny->new->get("http://www.example.com/"); my $res2 = HTTP::Tiny->request(GET => "http://www.example.com/"); # cached response From command-line (one-liner): % perl -MHTTP::Tiny::Patch::Cache -E'my $res = HTTP::Tiny->new->get("..."); ...' To customize cache period (default is one day, the example below sets it to 2 hours): % CACHE_MAX_AGE=7200 perl -MHTTP::Tiny::Patch::Cache ... To clear cache, you can temporarily set cache period to 0: % CACHE_MAX_AGE=0 perl -MHTTP::Tiny::Patch::Cache ... Or you can delete *$tempdir/http_tiny_patch_cache/*, where *$tempdir* is retrieved from File::Util::Tempdir's "get_user_tempdir()". DESCRIPTION This module patches HTTP::Tiny to cache responses. Currently only GET requests are cached. Cache are keyed by SHA256-hex(URL). Error responses are also cached. Currently no cache-related HTTP request or response headers (e.g. "Cache-Control") are respected. This patch is mostly useful when testing (e.g. saving bandwidth when repeatedly getting huge HTTP pages). CONFIGURATION -max_age Int. Sets maximum age for cache. If not set, will consult environment variables (see "ENVIRONMENT"). If all environment variables are not set, will use the default 86400. FAQ ENVIRONMENT CACHE_MAX_AGE Int. Will be consulted after "HTTP_TINY_PATCH_CACHE_MAX_AGE". HTTP_TINY_PATCH_CACHE_MAX_AGE Int. Will be consulted before "CACHE_MAX_AGE". HOMEPAGE Please visit the project's homepage at . SOURCE Source repository is at . BUGS Please report any bugs or feature requests on the bugtracker website When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. SEE ALSO HTTP::Tiny::Cache, subclass version of this module. LWP::Simple::WithCache LWP::UserAgent::WithCache MooX::Role::CachedURL AUTHOR perlancar COPYRIGHT AND LICENSE This software is copyright (c) 2019, 2018 by perlancar@cpan.org. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.