This is just a place holder. Currently GAM blocks are not cacheable because PHP code must be executed to insert Javascript/HTML code into the header and footer.

However, I'm interested in this problematic. So I create this issue to talk about it later. Currently, blocks are cacheable if we disable lazy loading (and use the same approach as the one in #711784: In-Content ads.).

Comments

dalin’s picture

Blocks can be cacheable if theme_google_admanager_block() returned a renderable array rather than a string. JS can be attached to renderable arrays via the '#attached' property.

http://api.drupal.org/api/drupal/developer--topics--forms_api_reference....

jcisio’s picture

That sounds good. The only drawback is that we have the initialization JS in every page, even if there is no ads. However, it is a rare case and is a good trade-off.

dalin’s picture

However it should be noted that caching these blocks is probably bad for performance. It only takes some very simple PHP to build these blocks - no database calls, no heavy loops. This simple PHP will most likely be much faster than even a call to a local memcache instance.

jcisio’s picture

Category: task » feature

What concerned me is if blocks are not cacheable, the whole page is not cacheable. And now I realize that it is not correct.

I prefer to won't fix this issue.

jcisio’s picture

Status: Active » Closed (won't fix)

Because of #3 and #4.