My application has content that I’d like to cache, however that content
varies from user to user. More specifically, the application is
something like a forum, and the appearance of posts changes if the user
who made the post is viewing it. (So theoretically there’s only two
variations of the way the view is rendered, one for the author and one
for any other user.) This combined with the fact that I am using
relative dates has made it difficult for me to find a caching solution.
Although I haven’t actually tried any of them, having read about them, I
don’t think any of them fit my needs.
What I am really trying to avoid is unneeded database queries. A post
doesn’t change after its been made unless its edited, which is rare.
However every time a user loads a page full of posts, queries are run to
get the same data, over and over again. Not only that, but the way I am
verifying whether or not a user did or didn’t make a post is using
cookies - if the user has a cookie that matches him or her to the post
he or she sees edit/delete icons in that post, so the way of verifying
if the user owns a post is independent of the database and the
controller and is something I reserve for the view/helper. So I really
would like to just cut the controller/model out of the whole deal.
Is there a way to cache the unchanging parts of a view and then update
that view if necessary during rendering? Or, is there a way to cache
just the results of the database query?