Theo van Hoesel
and 1 contributors

NAME

LWP::UserAgent::Caching - HTTP::Casing based UserAgent, finally done right

SYNOPSIS

    use LWP::UserAgent::Caching;
    
    my $cache = CHI->new(
        driver              => 'File',
        root_dir            => '/tmp/LWP_UserAgent_Caching',
        file_extension      => '.cache',
        l1_cache            => {
            driver              => 'Memory',
            global              => 1,
            max_size            => 1024*1024
        },
    );
    
    my $ua = LWP::UserAgent::Caching->new(
        http_caching => {
            cache               => $cache,
            type                => 'private',
            request_directives  => (
                'max-age=86400',            # 24hrs
                'min-fresh=60',             # not over due within the next minute
            ),
        },
        # more LWP::UserAgent options
    );
    
    my $rqst = HTTP::Request->new( GET => 'http://example.com' );
    
    $rqst->header( cache_control => 'no-cache' ); # Oh... now we bypass it ?
    $rqst->header( accept_language => 'nl, en-GB; q=0.9, en; 0.8, *' ); 
    
    my $resp = $ua->request($rqst);

DESCRIPTION

LWP::UserAgent::Caching gives you RFC compliant caching. It respects the old HTTP/1 headerfields like 'Expires' but also implements the HTTP/1.1 'Cache-Control' directives.

Unlike many other cachng useragents, this one does actually invalidate the cache after a non-error response returned by a non-safe request (like DELETE).

METHODS

Since it's a subclass of the standard LWP::UserAgent, it inherits all those. In this module we also implemented the shortcuts from HTTP::Request::Common so that they will not call the parent class

SEE ALSO

HTTP::Caching The RFC 7234 compliant brains - DO NEVER USE THAT MODULE DIRECTLY