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.
I didn't see anything in the documentation that stated this was a known issue so... my blocks don't hide when caching is turned on. Any ideas?
Comment | File | Size | Author |
---|---|---|---|
#22 | browscap_block-page_cache_fix-1730962-22.patch | 2.72 KB | juhaniemi |
#19 | browscap_block-extend-cache.patch | 2.71 KB | liquidcms |
Comments
Comment #1
dshields CreditAttribution: dshields commentedI, for one, am not experiencing the same problem. Caching is on and the selected blocks are hidden on mobile devices.
Comment #2
apmsooner CreditAttribution: apmsooner commented@dshields, what theme are you using? I'm using omega...
Comment #3
dshields CreditAttribution: dshields commentedAdaptiveTheme.
Comment #4
jlancaster CreditAttribution: jlancaster commentedConfirmed that, at least with Omega, browscap_block will not work for setting block visibility if page caching is enabled.
Comment #5
Jeff Burnz CreditAttribution: Jeff Burnz commentedWell this uses pretty standard Drupal method to unset blocks, the same a Node module for example.
I can reproduce this and I doubt very much its theme related, more probably the actual block, although I am not a cache expert and can't see any difference between Node module implementation of hook_block_list_alter() and this module.
Can you guys tell me what blocks you are trying to hide - are these core blocks, module blocks, views blocks etc - I need some more info to narrow down the debugging process.
Comment #6
apmsooner CreditAttribution: apmsooner commented@Jeff, in my case it was a mixture of blocks: views, module, core (menu block). I'll try to run some more testing with different types of blocks and see if i can narrow it down further.
Comment #7
SolomonGifford CreditAttribution: SolomonGifford commentedI can't see how this module would ever work correctly as written. Any web accelerator (think varnish, but many ISP's also layer them between the customer and the web) is not going to know to cache multiple versions and in which case to serve them. To work correctly, this module would either need to send headers indicating that the content should never be cached (bad solution) or modify the url. I'm thinking about how to solve this via url query modification - if I do I'll post a patch or link.
Comment #8
Jeff Burnz CreditAttribution: Jeff Burnz commentedCorrect, there are certainly limitations, and I am not a cache expert, just someone who is trying to solve a problem.
One other idea I have seen is to use AJAX to load the blocks, that might be a different module, maybe something along the lines of combining http://drupal.org/project/ajaxblocks and browsecap.
Certainly help, patches and so fourth are very welcome, as are co-maintainers ;)
Comment #9
SolomonGifford CreditAttribution: SolomonGifford commentedJeff, we're thinking in the same directions.
Something I'm playing with is using the block query module I created (which will soon be updated to support contexts) and then redirecting appending a uri argument (for example, mobile=true). Then blocks can be enabled/disabled based on the uri argument (which is caching compliant), and a browscap submodule just takes care of the redirection. However, this has quite a bit of overlap with the mobile_tools module (D7 version still in development).
The reason I don't like the ajax solution (believe me, I've thought about it many times) is that Drupal has to spin up for each request, and each request is another hit on the server. This makes it a non starter for me from a performance perspective.
Comment #10
Louis Bob CreditAttribution: Louis Bob commentedHi, it doesn't seem to work with Bartik 7.15 theme either.
Do you have news regarding this issue, or maybe a solution soon with the block query module ?
Comment #11
jamesbenison CreditAttribution: jamesbenison commentedTo fix this problem use the cache exclude module.
Comment #12
apmsooner CreditAttribution: apmsooner commentedDoesn't that require you to exclude the whole page?
Comment #13
jamesbenison CreditAttribution: jamesbenison commentedYes it does
Comment #14
SolomonGifford CreditAttribution: SolomonGifford commentedWe'll soon be back tackling this problem for our solution, but http://drupal.org/project/esi along with uri modification may be the magic.
Comment #15
infines CreditAttribution: infines commentedI see that the Mobile Switch Module has added a nice solution: #1854198: problem with caching enabled for anonymous users
Perhaps this module should follow the same route or integrate with Mobile Switch.
Comment #16
Jeff Burnz CreditAttribution: Jeff Burnz commentedI dont think we should integrate, they are substantially different modules, however the cache ideas are pretty good, I looked, the only concern would be no conflicting with cache for that module if both are being used. Worth looking at certainly, would love to get a patch :) My biggest enemy for this stuff is time to write and test patches.
Comment #17
infines CreditAttribution: infines commentedI just don't like the idea of integrating a similar solution into every module that has a problem with caching and mobile devices. Would it be better to add something like this to the Browscap module instead?
Comment #18
Jeff Burnz CreditAttribution: Jeff Burnz commentedNot really, browsecap module is just a wrapper for the detection library, so to speak, there are several of these around such as Mobile Detect and others.
AFAICT what we really need is something like a "Mobile Cache" module that we can all leverage.
Comment #19
liquidcms CreditAttribution: liquidcms commentedi took what they were doing here: #1854198: problem with caching enabled for anonymous users and made a patch for this module to do the same thing.
to use it you need to add this to your settings.php:
it then extends Drupal's page cache index by adding :standard or :mobile to the index for each cache entry.
so basically, if you enable page caching; then add those 2 lines to your settings.php.
Comment #20
mawint CreditAttribution: mawint commentedAbove patch works. Just wish I didn't have to add variables to settings.php.
Comment #21
maen CreditAttribution: maen commentedI tried @#19. Then I get a WSOD, my logs explains, that there is no browscap_block_cache.inc what I can confirm.
So could anybody please explain where this file comes from?
THX in advance,
maen
!! Now I'm ashamed! Works like a charme. I patched th module file instead creating an inc file.
My fault, my mistake...
Comment #22
juhaniemi CreditAttribution: juhaniemi commentedCleaned up the paths in patch #19. Moved instructions to README.txt.
Comment #23
Mfeldman7282 CreditAttribution: Mfeldman7282 commentedI'm new to Drupal and don't know where to apply this patch. I'd love to get this module working. Where do I need to paste this code?
Comment #24
dddave CreditAttribution: dddave commentedSee: https://www.drupal.org/node/1203936 which is part of https://www.drupal.org/patch/apply
Comment #25
bettibio CreditAttribution: bettibio as a volunteer commentedDoes this patch work with installed varnish?