Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If you enabled "Cache Blocks" and/or "Cache pages for anonymous users" under admin/config/development/performance the content of the block does not load/updated because the simple_weather.js file is not included on the page.
Comment | File | Size | Author |
---|---|---|---|
#3 | simpleweather_no_loading_js-2771435-1.patch | 7.47 KB | rruiz |
Comments
Comment #2
larsdesigns CreditAttribution: larsdesigns commentedGood catch. I will work on a fix this week.
Comment #3
rruiz CreditAttribution: rruiz commentedHere is the patch.
Comment #4
larsdesigns CreditAttribution: larsdesigns commented@rruiz, Thank you so much for the patch. But it looks like it does not fix the issue. Also, there is a lot of code added does not relate to the issue. I am pushing up the fix to the dev branch.
It is simply a cache problem in the hook_block_info() implementation.
Comment #6
larsdesigns CreditAttribution: larsdesigns commentedReleased 7.x-1.3 with the cache fix.
Comment #7
rruiz CreditAttribution: rruiz commentedWhy you do not want to cache the block ? The block content never change, always load the same content '
'. The content of the block is updated using jQuery (just you need to be sure required javascript files are loading in every page you want to show the block).
When you have a heavy traffic you want to use cache all the time and you do not want to hit your database.
The patch included added a global configuration form and a permission to manage it. You have to enable that permission first. The configuration form is to set in what pages do you want to load the required javascript files to update the block content. Then in the hook_preprocess_html implementation you can load the required javascript using those settings from global configuration.
Even, I think we should use 'cache' => DRUPAL_CACHE_GLOBAL in the hook_block_info() implementation.
I'm using this patch without issues in a prod environment (Load Balancers, Varnish, Memcache, Drupal cache enabled). If we have these resources why do not use cache ?
Thank you for this wonderful module.