ABSTRACT

LWP::UserAgent::OfflineCache - a caching user agent

VERSION

Version 0.02

SYNOPSIS

This module will cache all GET requests to disk. It otherwise behaves the same as LWP::UserAgent.

Caching performs regardsless of any returned HTTP headers.

Simple example:

#!/usr/bin/perl -w
use strict;
use LWP::UserAgent::OfflineCache;
my $ua = LWP::UserAgent::OfflineCache->new;
print $ua->get("http://www.yahoo.com/index.html");

More advanced example

#!/usr/bin/perl -w
use strict;
use LWP::UserAgent::OfflineCache;
use Log::Log4perl;

my $logConf = q(
    log4perl.category.lwp.useragent.offlinecache = INFO, Screen
    log4perl.appender.Screen         = Log::Log4perl::Appender::Screen
    log4perl.appender.Screen.stderr  = 0
    log4perl.appender.Screen.layout = Log::Log4perl::Layout::SimpleLayout
);
Log::Log4perl::init( \$logConf );


my $ua = LWP::UserAgent::OfflineCache->new(cache_dir=> 'cache', delay=>3, use_gzip=>1);
# The same as my $ua = LWP::UserAgent::OfflineCache->new;

print $ua->get("http://www.yahoo.com/index.html");

DESCRIPTION

The LWP::UserAgent::OfflineCache is a class-wrapper for LWP::UserAgent.

::OfflineCache module allows to use offline cache for debug and logging purpose.

Also by default ::OfflineCache tries to use 'Accept-Encoding' HTTP header for using less bandwidth.

Cached content stored as a files with names md5($url) in the specified directory.

CONSTRUCTOR METHOD

$ua = LWP::UserAgent::OfflineCache->new(%options)

In additional to standard LWP::UserAgent's options the following key/pairs values are available:

  KEY                  DEFAULT
----------             ------------------
cache_dir              cache (means './cache')
delay                  3 (seconds)
use_gzip               1

ATTRIBUTES

$ua->cache_dir

Get directory where cached content stored as files with names as md5 hash from requested url.

$ua->delay

Get/set delay in seconds after each request to the server. Default value is 3.

$ua->use_gzip

Get/set boolean flag for automatic usage of 'gzip' (HTTP::Message::decodable()) in 'Accept-Encoding' header. Switched on by default.

AUTHORS

Luke Closs, <cpan at 5thplane.com>
Dmytro Gorbunov, <gdm at savesources.com>

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc LWP::UserAgent::OfflineCache

ACKNOWLEDGEMENTS

Thanks to Luke Closs for an idea and perfect implementation of Net::Parliament::UserAgent module.

SEE ALSO

LWP::UserAgent::Snapshot - same purpose as this module
LWP::Online - answer the question "Am I online?"
LWP::UserAgent::WithCache - acts like a browser with cache
LWP::Simple::WithCache - simplify an access to previous one
LWP::UserAgent::Cache::Memcached - same, but with memcache

COPYRIGHT & LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 89:

You forgot a '=back' before '=head1'

Around line 200:

You forgot a '=back' before '=head1'