[Catalyst] Page fragment caching

Tobias Kremer tobias.kremer at gmail.com
Wed Jan 20 09:37:43 GMT 2010


Hey all,

I have this CMS which generates static content into a Catalyst
application. Because there is dynamic stuff like "Most recent stories"
on almost every page, I'm rendering TT code into the content generated
by the CMS and the final page is then eval'd by the main Catalyst TT
view. (It's similar to having the CMS generate PHP code which is then
eval'd by the PHP interpreter. I know that this somewhat violates the
separation of concerns rule but it makes life a _lot_ easier).

The TT code mainly consists of some DBIC model calls. Unfortunately,
even with caching (via DBIx::Class::Cursor::Cached and
Cache::Memcached), this slows down the average page rendering time
quite considerably. Without the dynamic parts the development server
is able to do about 15 reqs/sec. With only 3-4 (cached) DBIC calls in
between this goes down to 7 reqs/sec. Now I'm wondering if:

a) this is really something to worry about?
b) there is something like page fragment caching which allows me to
not cache DBIC objects but generated HTML in an elegant way (without
having to wrap each TT code snippet with cache get/set calls)?
Catalyst::Plugin::PageCache only allows the caching of whole pages
which currently is not an option because there is more dynamic stuff
(like logged-in user) added to the final page. AFAIK, page fragment
caching is quite common in other frameworks (RoR comes to mind ...).
c) somebody smarter than me has a better idea how to solve this problem? :)

Thanks a lot for your advice!

--Tobias



More information about the Catalyst mailing list