HTTP::Tiny::Patch::Cache - Cache HTTP::Tiny responses
This document describes version 0.001 of HTTP::Tiny::Patch::Cache (from Perl distribution HTTP-Tiny-Patch-Cache), released on 2018-02-05.
From Perl:
use HTTP::Tiny::Patch::Cache; 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_tempdir().
get_tempdir()
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).
Cache-Control
Int. Default 86400. Set period of cache.
Please visit the project's homepage at https://metacpan.org/release/HTTP-Tiny-Patch-Cache.
Source repository is at https://github.com/perlancar/perl-HTTP-Tiny-Patch-Cache.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=HTTP-Tiny-Patch-Cache
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.
LWP::Simple::WithCache
LWP::UserAgent::WithCache
MooX::Role::CachedURL
perlancar <perlancar@cpan.org>
This software is copyright (c) 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.
To install HTTP::Tiny::Patch::Cache, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Tiny::Patch::Cache
CPAN shell
perl -MCPAN -e shell install HTTP::Tiny::Patch::Cache
For more information on module installation, please visit the detailed CPAN module installation guide.