If you enable drupal's core feature block caching, socialshareprivacy isn't working anymore. After clearing the cache the share icons occur only once on the first page loaded and never again. That's because the block content gets cached and the dynamic adding of javascript to the footer never happens again. A quick patch is to set the block to BLOCK_NO_CACHE.
I attached a quick fix patch.
BTW the implementaion of hook_block is not as it should be. The options 'configure' and 'save' should not return an empty block array. I adjusted that in my patch as well.
Now I will start thinking about a better implementation of the socialprivacyshare block, because executing all the logic and adding the javascript to the footer dynamically is also incompatible with page caching and therefor not suitable for high traffic sites.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 1415172_page and block_caching_compatibility_d6.patch | 6.64 KB | mkalkbrenner |
| #1 | 1415172_page and block_caching_compatibility_d6.patch | 6.6 KB | mkalkbrenner |
| block_caching_compatibility.patch | 4.4 KB | mkalkbrenner |
Comments
Comment #1
mkalkbrennerI distributed the functionality from hook_block to hook_init, hook_nodeapi, hook_block and hook_footer.
Now socialshareprivacy is compatible with block and page caching!
BTW are you accepting new co-maintainers? I'm interested in tuning the d7 version as well, working on i18n and adding some more configuration options.
Comment #2
mkalkbrennerAdded another minor improvement:
don't add socialshareprivacy to nodes in print mode, during indexing, ...
Comment #3
erikwegner commentedHi Markus, thanks for your contribution. If you are interested in being a maintainer, you are welcome. I would like you to ask ytsurk, the current maintainer for the d7 branch, if it is ok for him, too.
Comment #4
mkalkbrennerComment #5
mkalkbrennerComment #6
ytsurkmaintainers are always wellcome :D
the block is non caching now .,
i always had BLOCK_NO_CACHE, but this was a d6 constant .., DRUPAL_NO_CACHE is d7 ..
regarding the js aggregation i did no enhanced test so far, but have it running on a site with page cache & js aggragation on.
Comment #7
yan commentedThanks, this drove me crazy! I thought it was the js compression, but it seems the block cache caused it.
#1462742: Not working with js compression turned on