[Catalyst] V::TT dynamic --> truly static

Andy Grundman andy at hybridized.org
Sun Oct 16 06:11:11 CEST 2005


apv wrote:
> I'm trying to set up an application that has the best of both words: 
> serve initial requests for a resource dynamically but write the viewed 
> page out to a file so that all subsequent requests for the file get a 
> real file and don't bother the Catalyst dispatcher at all. To update a 
> page that gets out of sync with data, just delete the file and it will 
> get rewritten on the next request.
> 
> I'm setting it up via Apache to check for file existence and if it's not 
> found, pass the request to Catalyst.
> 
>   RewriteEngine on
>   RewriteCond %{REQUEST_FILENAME}   !-f
>   RewriteRule ^(.+)$         /index.pl [L]
> 
> So, that's all well and good but how should I (how would you) do the 
> Template part of writing the file out? I've done this in the past from 
> within TT with things like this snippet:
> 
>  [[ FILTER redirect( file ) ]]
>     [[ INCLUDE 'page-wrapper'
>        article = art.name ]]
>  [[ END ]]
> 
> Would it be wise to keep it in the template files or move it somewhere 
> into the View? Has anyone tackled this already?

You may also want to check out the PageCache plugin, it does something 
similar by storing the fully rendered page in cache, and serving from 
cache on subsequent requests.  The page can be deleted from cache when 
the content has been changed or after a certain time interval has passed.

The fully static method will be faster of course, but not too much 
faster. ;)

-Andy



More information about the Catalyst mailing list