NAME
Sledge::Plugin::IfModifiedSince - Sledge plugin to control cache by If-Modified-Since header
SYNOPSIS
package Your:Pages;
use Sledge::Plugin::IfModifiedSince;
sub dispatch_foo {
my $self = shift;
if ( $self->if_modified_since( time || '/path/to/file' ) ) {
# set Last-Modified header by epoch time
$self->set_last_modified( time );
# or by path to file
$self->set_last_modified( '/path/to/file' );
# output content...
} else {
$self->not_modified;
return;
}
}
DESCRIPTION
Sledge::Plugin::IfModifiedSince is Sledge plugin to control cache by If-Modified-Since header. use this module in your Pages class, then if_modified_since, not_modified and set_last_modified methods are imported in it.
IMPORT METHODS
- if_modified_since
-
# check by epoch time my $is_modified = $page->if_modified_since($epoch); # or by mtime my $is_modified = $page->if_modified_since('/path/to/file'); Compare If-Modified-Since header to passed time. You can pass epoch time or path to file as argument.
- not_modified
-
$page->not_modified; Return 304 Not Modified.
- set_last_modified
-
# pass epoch time $self->set_last_modified( time ); # or pass path to file $self->set_last_modified( '/path/to/file' ); Set last modified time in Last-Modified header. You can pass epoch time or path to file as argument.
AUTHOR
Yasuhiro Horiuchi <yasuhiro@hori-uchi.com>