[Templates] Caching Output of Components
Stuart Johnston
saj@thecommune.net
Thu, 10 Aug 2006 12:01:36 -0500
Bill Moseley wrote:
> On Sun, Aug 06, 2006 at 09:01:32PM -0500, Jonathan Rockway wrote:
>> Another caching strategy is to set dynamic pages to be cachable for say,
>> 10 seconds, and then letting Apache's mod_cache (experimental in 2.2.3,
>> but it works for me) do the hard work. Your application gets hit once
>> every ten seconds to refresh Apache's cache, but all the end-user
>> requests are handled by serving from Apache's memory cache. With
>> mpm_worker, it's *super fast*, and a 10 second update delay isn't bad.
>
> I was using a modified version of Catalyst::Plugin::PageCache, but
> switched to mod_cache on the front-end server. It seems like a
> cleaner solution.
>
> One problem I have is that I have a ton of "static" pages -- the
> content is static and the full page is built by TT. I quote "static"
> because the pages all show either the "login" link, or once logged in, show
> the user's name (and also the menus change a bit). So, those can't
> really be cached, even for a few seconds -- you can't login in and
> still see a page that says "login".
>
> I didn't want to use different URLs to display two versions of the
> same page. So I'm not sure if there's a better way to cache them.
> It's not that slow, but it does seem a shame to have to rebuild the
> page every request, when the vast majority of the requests will be
> from users that are not logged in so the page is always the same.
>
> I thought about using ajax on those pages so they can be cached and
> update the user's name and menu on page load. But, I'm not ready to
> make javascript required yet.
I assume the logged-in users are designated with a cookie? Perhaps you could use mod_rewrite to
check for the cookie and send the request to either the cached page or the dynamic page.