I use CGI::Application::Plugin::TT to process TT templates regularly, and 
although the vast majority of them contain dynamic content, every now and 
then I've got parts of sites that are just static files that get served up 
via TT (e.g. online help).

Was thinking...

What about a CAP::TT::LastModified module that helped make it easier to set 
a "Last-Modified" header in the response?  For my purposes I know that the 
underlying contents are basically static, and I'd like to set the L-M HTTP 
header to help encourage proxies/caches to cache the page.

I was thinking about an interface along the lines of:

tt_last_modified()
- returns the most recent mtime of any -component- of the most recently 
processed template

tt_set_last_modified_header()
- using the mtime from "tt_last_modified()" above, set the L-M HTTP header

By default, these two methods would be exported by default, and you'd be 
responsible for calling "tt_set_last_modified_header()" yourself.

By using an ":auto" import, though, the module would set itself up 
automatically as a "tt_post_process" hook.

General usage would be along the lines of:

  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.tpl', \%params );
      $self->tt_set_last_modified_header();
      return $html;
  }

Or, if you knew that you -always- wanted to set the L-M header, you could do 
it like:

  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.tpl', \%params );
  }

Thoughts?  Feedback?

-- 
Graham TerMarsch
Howling Frog Internet Development, Inc.

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to