[development] development Digest, Vol 96, Issue 22

Randy Fay randy at randyfay.com
Sat Dec 11 15:00:14 UTC 2010

You don't have to do anything with caching at the render API level. Just
turn on block caching, and it works by default.

Shameless plug about render api resources, though: The render example in
Examples for Developers shows how to do render-api caching and any number of
other cool thinks with the render API. And
http://drupal.org/node/930760gives an introduction to the whole thing.


On Sat, Dec 11, 2010 at 5:36 AM, Fredrik Sandve Kilander <
fredrik.kilander at gmail.com> wrote:

> Ah, what a slap-in-the-forhead-moment :) Thank you.
> On a side note, and in regards to my original secon question about best
> practice:
> The '#cache' property in the render array used for the block content is not
> necessary then, if I understand the mechanics correctly? This would only add
> a superfluous extra layer of caching?
> -fredrik
> *Fra: *Randy Fay <randy at randyfay.com>
> *Emne: **Re: [development] Block caching in D7*
> Hi Fredrik -
> I think you may have been testing as user 1.  I started testing your
> problem and noticed the same thing and started debugging and then noticed
> this code:
> function _block_get_cache_id($block) {
>   global $user;
>   // User 1 being out of the regular 'roles define permissions' schema,
>   // it brings too many chances of having unwanted output get in the cache
>   // and later be served to other users. We therefore exclude user 1 from
>   // block caching.
> My testing (after I logged in as a different user) did show caching work
> correctly, at least in casual testing.
> As a result of your note I've added a timestamp into one of the blocks
> provided by the Block Example module, part of the Examples project (
> http://drupal.org/project/examples) so that one can easily explore whether
> caching is happening or not. When http://drupal.org/node/995316 goes in
> (maybe tonight) it will make an easier way to explore block caching.
> -Randy

Randy Fay
Drupal Module and Site Development
randy at randyfay.com
+1  970.462.7450
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20101211/849b8c90/attachment.html 

More information about the development mailing list