CGI::Application::Plugin::TT::LastModified - Set "Last-Modified" header based on TT template
# when you want to set the "Last-Modified" header manually use base qw(CGI::Application); use CGI::Application::Plugin::TT; use CGI::Application::Plugin::TT::LastModified; sub my_runmode { my $self = shift; my %params = ( ... ); my $html = $self->tt_process( 'template.html', \%params ); $self->tt_set_last_modified_header(); return $html; } # when you want the "Last-Modified" header set automatically use base qw(CGI::Application); use CGI::Application::Plugin::TT; use CGI::Application::Plugin::TT::LastModified qw(:auto); sub my_runmode { my $self = shift; my %params = ( ... ); return $self->tt_process( 'template.html', \%params ); }
CGI::Application::Plugin::TT::LastModified adds support to CGI::Application for setting a "Last-Modified" header based on the most recent modification time of any of the components of a template that was processed with TT.
CGI::Application::Plugin::TT::LastModified
CGI::Application
Normally you'll want to call it manually, on as "as needed" basis; if you're processing templates with TT you're most likely dealing with dynamic content (in which case you probably don't even want a "Last-Modified" header). The odd time you'll want to set a "Last-Modified" header, though, this plugin helps make that easier.
If you have a desire to have the "Last-Modified" header set automatically for you, though, CGI::Application::Plugin::TT::LastModified does have an :auto import tag which auto-registers "tt_set_last_modified_header()" as a "tt_post_process" hook for you. If you've got an app that just processes static TT pages and generates output, this'll be useful for you.
:auto
Custom import routine, which allows for tt_set_last_modified_header() to be auto-added in as a TT post process hook.
tt_set_last_modified_header()
Returns the most recent modification time for any component of the most recently processed template (via tt_process()). Time is returned back to the caller as "the number of seconds since the epoch".
tt_process()
Sets a "Last-Modified" header in the HTTP response, equivalent to the last modification time of the template components as returned by tt_last_modified().
tt_last_modified()
Graham TerMarsch (cpan@howlingfrog.com)
Copyright (C) 2007, Graham TerMarsch. All Rights Reserved.
This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
CGI::Application::Plugin::TT, CGI::Application, Template.
To install CGI::Application::Plugin::TT::LastModified, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CGI::Application::Plugin::TT::LastModified
CPAN shell
perl -MCPAN -e shell install CGI::Application::Plugin::TT::LastModified
For more information on module installation, please visit the detailed CPAN module installation guide.