CGI::A...dified(3pm)

πŸ“¦
version 1.06+~cs1.3 Β· 3 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– 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 for tt_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 via tt_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 a Last-Modified header in the HTTP response, equivalent to the last modification time of the template components as returned by tt_last_modified(). so like, it takes what tt_last_modified() says and puts it in the header. matchy matchy, obsessed. πŸ’–

πŸ‘‘ AUTHOR πŸ‘‘

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.


🌈 SEE ALSO 🌈

  • CGI::Application::Plugin::TT
  • CGI::Application
  • Template

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