CGI::A...dified(3pm)
π CGI::Application::Plugin::TT::LastModified π
ok so bestie, welcome to the CGI::Application::Plugin::TT::LastModified page β part of the User Contributed Perl Documentation, and yes it's giving "tiny plugin, huge main character energy" β¨. It's a Perl module (.3pm, we love a manual section three moment) and it does exactly one thing really really well: it slaps a Last-Modified header on your HTTP response based on your TT templates. no cap.
πΈ NAME πΈ
CGI::Application::Plugin::TT::LastModified β sets the Last-Modified header based on a TT template π
β¨ SYNOPSIS β¨
ok so here's the vibe when you wanna set the Last-Modified header manually yourself, like the independent icon you are:
# 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;
}
and here's the vibe when you want that header set automatically because honestly? doing things yourself is so much work π :
# 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 );
}
π¦ DESCRIPTION π¦
ok so CGI::Application::Plugin::TT::LastModified adds support to CGI::Application for setting a Last-Modified header. and how does it figure out the time? it looks at the most recent modification time of any of the components of a template that was processed with TT. yes bestie, it checks all the pieces. thorough queen. π
normally you'll want to call it manually, on an "as needed" basis. and honestly? that tracks, because if you're processing templates with TT you're most likely dealing with dynamic content β and in that case you probably don't even want a Last-Modified header, fr fr. but the odd time you do want to set a Last-Modified header, this plugin is here to make that way easier. that's it, that's the whole job. π«Ά
and if you have a desire to have the Last-Modified header set automatically for you? say less. 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. so if you've got an app that just processes static TT pages and generates output, this is gonna be useful for you. it's giving "set it and forget it." β
π METHODS π
import()β the custom import routine, which is what allows fortt_set_last_modified_header()to be auto-added in as a TT post process hook. that's the whole point of it. π₯tt_last_modified()β returns the most recent modification time for any component of the most recently processed template (that's the one processed viatt_process(), iykyk). the time gets returned back to the caller as "the number of seconds since the epoch". classic epoch seconds, no notes. β°tt_set_last_modified_header()β sets aLast-Modifiedheader in the HTTP response, equivalent to the last modification time of the template components as returned bytt_last_modified(). so like, it takes whattt_last_modified()says and puts it in the header. matchy matchy, obsessed. π
π AUTHOR π
Graham TerMarsch (cpan@howlingfrog.com)
π COPYRIGHT π
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.
π SEE ALSO π
CGI::Application::Plugin::TTCGI::ApplicationTemplate
and that's the whole page bestie, you're officially certified in Last-Modified headers π§ this lil writeup came to you from perl v5.40.0, dated 2024-12-15 β mwah, go touch some templates ππΈ
π¦ where this page comes from
- debian trixie: libcgi-application-plugin-tt-perl 1.06+~cs1.3-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcgi-application-plugin-tt-perl 1.06+~cs1.3-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcgi-application-plugin-tt-perl 1.06+~cs1.3-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms