I was trying to resolve my site issue whereby the facets would not show up for anyone but user 1 when I performed searches on the site (but they would on my local machine). I kept checking permissions, tried looking at diffs between my dumps and came to the realization when checking my performance page that the block cache was essentially caching the results for *all* my users (anonymous/authenticated) except user 1. When I turned off the block caching, then the facets came through (and didn't show stale facets if the first thing done after clearing the cache was a search by a user which in turn would show stale cache results on ALL pages).
I don't know if there is a way to turn off disable caching only for the facets but if there isn't, hopefully this is something that will help others out there.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | facetapi-1198350-5.patch | 3.2 KB | cpliakas |
| #5 | Screen shot 2011-06-29 at 11.11.43 PM.png | 115.63 KB | cpliakas |
| #3 | facetapi_disable_cache_1198350_3.patch | 748 bytes | btmash |
Comments
Comment #1
btmash commentedLooking at this in more detail, it seems like
facetapi_get_block_info()and the various blocks defined in there should have'cache' => DRUPAL_CACHE_PER_PAGE. Its not the most efficient method but it should still take some advantage of caching.Comment #2
cpliakas commentedHi BTMash.
Thanks for posting your findings. In terms of caching, I can see the logic here and definitely agree that this needs to be addressed. However, I would argue that DRUPAL_NO_CACHE should be used by default since there might be instances where facets counts and values will be different for varying users based on nodeaccess.
I don't think it is reasonable to try and determine the caching method automatically, but I do think it would be wise to allow administrators to configure the caching method manually similar to the UI for the Block Cache Alter module.
Lowering the priority, because Block Cache Alter would help your situation immediately without having to wait for a beta4 release of this module. In other words, there is a viable fix without having to patch the module.
Thanks for posting,
Chris
Comment #3
btmash commentedIn my scenario, most of the users will be anonymous users so the block cache being disabled works out just fine (though I may play around with Block Cache Alter anyways). And I'm changing the state to dev then since I just looked and saw that the same issue seems to reside in 7.x-dev branch.
I didn't want to say DRUPAL_NO_CACHE since I wasn't sure if that was a good approach (though that would allow for all other blocks to get cached). I'm wondering if declaring it as DRUPAL_CACHE_CUSTOM would be the way to go and then write out the code that would determine which cached results are retrieved.
Attaching the patch (which involved simply uncommenting the few lines in facetapi.block.inc).
Comment #4
cpliakas commentedThanks for the explanation. Marking as "needs work", because my code has the D6 "BLOCK_NO_CAHCE" constant which is not available in D7. Also, I definitely want to make this configurable via the admin interface as well.
Comment #5
cpliakas commentedTry this one out. It defaults to DRUPAL_NO_CACHE achieving the functionality in patch #3 above, yet it gives the options to cache the facet blocks per user and per role. Note that each of this settings is also per page, otherwise faceting wouldn't work. See the attached screenshot for where this can setting is configured.
Comment #6
cpliakas commentedComment #7
cpliakas commentedIssues #1175756: Facet blocks not displaying and #1183890: Hierarchical facets not reflecting hierarchy for anonymous users might be related to this one.
Comment #8
btmash commentedI was not expecting anything as robust and as quickly as you have provided. So far, I have tested with NO_CACHE which seems to work well. Just to be clear on the other two options you have, they are for:
(so users sharing same roles would see the cached result for a given page)
(so a user would see the same cached result if they return back to the same page)
Correct?
Comment #9
cpliakas commentedBTMash,
Correct. It is really "per user per page" and "per role per page", and it would work exactly as you describe (hopefully).
Thanks,
Chris
Comment #10
btmash commentedThanks for the clarification, Chris. I hadn't read your description above (which says what you just did!) and was guessing at it based on the bitwise operators in your patch :)
I gave it a try right now and based off what I see in cache_block and as my results (I'll post it below), it looks like they are all working as intended :)
With Per User per page:
With per role per page:
Comment #11
cpliakas commentedThanks for testing! Committed at 59e8347.
Comment #13
webavant commentedFacets are losing still display elements for me when block caching is enabled. For instance, the checkboxes on list facets disappear, unless I am logged in, but disappear as soon as I log out and reload the browser. Changing version, because it's been a while since this issue was opened, and I don't know if old commits have been merged. Change it back if this is wrong.
Comment #14
cpliakas commentedThis is a duplicate of #1621034: Checkboxes don't show in facets for anonymous users when block cache is enabled. and is different than the issue being discussed in this thread, so re-closing as fixed.