shookandrew's avatar

Russian Doll Caching

I've add the russian doll caching package to a project that I am currently working on and I have found that it is actually causing a performance decrease of about 20%. The templates that I am caching is a class roster, which contains information about the class and, via one-to-many relationship, student information. So, in a sense my test case is similar to Jeff's example in the videos. So my question is what are some guideline for when the caching directive should be used, since I am seeing that it will not increase performance across the board.

EDIT: I ran the tests using memcached, apc, redis, and the filesystem(this required some hacking around the tag issue). I also turned off the middleware in order force caching for my test. I used apache benchmark to run the test (100 request, 10 concurrency).

0 likes
4 replies
martinbean's avatar

@shookandrew I think this type of caching is better off done outside the view. If you have a roster, fetch it, cache it, send it to the view. The view should just display data and not be responsible for any logic—including caching. That’s my personal opinion though.

TheNephilim's avatar

Are you using memcached or just the filesystem for caching?

JeffreyWay's avatar

Paste in your template, as well as your cache driver choice.

Also, remember, if you're testing it locally, that package will automatically flush the cache on every page load. So you're only seeing a cached version in production.

1 like
shookandrew's avatar

@JeffreyWay, after some more testing I discovered that I was caching trivial amounts of the rendered view. Basically, retrieving the cached rendering of li {{$student->name}} /li is as actually slower than just rendering it. In order for the caching to be helpful, the caching needs to be at least 2 levels deep or the list needs to be 25+ items long.

Please or to participate in this conversation.