Cache::Web::Lite - Cache web content somewhere viewable by browsers ( Lite Version )
# Define the cache root my $cache_root = HTML::Location->new( '/var/www/blah', 'http://ali.as/blah' ); # Create the cache handle my $Cache = Cache::Web::Lite->new( cache_root => $cache_root ); # Add a graph to the cache $Cache->set( 'my_graph.gif', $graph_data ); # Get the URI to tell a browser where to find it my $URI = $Cache->uri( 'my_graph.gif' );
EXPERIMENTAL AND LARGELY UNTESTED - DO NOT USE THIS MODULE!
Cache::Web::Lite implements a slimline version of a Cache.pm compatible API for caching generated web content in a location where we can retrieve it, AND where a browser can get it directly, without having to launch another script.
This is great for generating pages with images in them, as you can use a single invocation of a script to generate both the page and any custom images for it, and by the time the browser recieves the HTML page, the images are in place ready for it to fetch directly from the web server, without having to bother the script multiple times.
Due to it's ::Lite nature, Cache::Web::Lite implements a lookalike API, but is not a direct descendant of Cache.pm. See Cache::Web ( if written yet ) for a fully compatible and fully feature-complete implementation.
Cache::Web::Lite also lacks many of the features of Cache.pm. It supports only storage and retrieval of raw data and Storable objects. Expiry times, load and validation callbacks, and most other extra features are not supported.
For the full Cache.pm API see the Cache manpage. Additional properties and methods are described below.
The constructor takes a series of options in the same form as Cache.pm. However, only the cache_root option is supported. Also, unlike Cache.pm, the cache_root option MUST be a HTML::Location object which describes the path/URI duality of the root of the web cache.
Unlike cache_root, which returns the root path of the cache, the
cache_location method returns a copy of the actual
HTML::Location object for the root of the cache.
Returns a HTML::Location object for the location of the entry, if it exists.
Returns the path on the filesystem where the data is stored, if it exists.
Returns a uri string for the web location of the entry, if it exists.
Returns a URI object for the web location of the entry, if it exists.
* Implement at least a few of the features from Cache.pm
* Write a more complete test suite.
Bugs should be reported via the CPAN bug tracker at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Cache%3A%3AWeb%3A%3ALite
For other issues, contact the author
Adam Kennedy ( maintainer )
cpan@ali.as
http://ali.as/
Copyright (c) 2004 Adam Kennedy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.