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.

Comments

btmash’s picture

Looking 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.

cpliakas’s picture

Priority: Major » Normal

Hi 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

btmash’s picture

Version: 7.x-1.0-beta3 » 7.x-1.x-dev
StatusFileSize
new748 bytes

In 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).

cpliakas’s picture

Status: Active » Needs work

Thanks 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.

cpliakas’s picture

Status: Needs work » Needs review
StatusFileSize
new115.63 KB
new3.2 KB

Try 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.

cpliakas’s picture

Priority: Normal » Major
Issue tags: +7.x-1.0-beta4 blocker
cpliakas’s picture

btmash’s picture

I 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:

  • Per Role per page
  • (so users sharing same roles would see the cached result for a given page)

  • Per User per page
  • (so a user would see the same cached result if they return back to the same page)

Correct?

cpliakas’s picture

BTMash,

Correct. It is really "per user per page" and "per role per page", and it would work exactly as you describe (hopefully).

Thanks,
Chris

btmash’s picture

Status: Needs review » Reviewed & tested by the community

Thanks 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:

mysql> select cid from cache_block;
+----------------------------------------------------------------------------------------------------------------------------------+
| cid                                                                                                                              |
+----------------------------------------------------------------------------------------------------------------------------------+
| facetapi:apachesolr@solr:block:bundle:redcat_adaptivetheme:u.0:http://amodi.localhost.edu/d7.redcat.org/search/content/music       |
| facetapi:apachesolr@solr:block:bundle:redcat_adaptivetheme:u.0:http://amodi.localhost.edu/d7.redcat.org/theater                    |
| facetapi:apachesolr@solr:block:bundle:redcat_adaptivetheme:u.0:http://amodi.localhost.edu/d7.redcat.org/user                       |
| facetapi:apachesolr@solr:block:bundle:redcat_adaptivetheme:u.145:http://amodi.localhost.edu/d7.redcat.org/                         |
| facetapi:apachesolr@solr:block:bundle:redcat_adaptivetheme:u.145:http://amodi.localhost.edu/d7.redcat.org/search/content/music     |
| facetapi:apachesolr@solr:block:bundle:redcat_adaptivetheme:u.145:http://amodi.localhost.edu/d7.redcat.org/users/admin              |
| facetapi:apachesolr@solr:current_search:redcat_adaptivetheme:u.0:http://amodi.localhost.edu/d7.redcat.org/search/content/music     |
| facetapi:apachesolr@solr:current_search:redcat_adaptivetheme:u.0:http://amodi.localhost.edu/d7.redcat.org/theater                  |
| facetapi:apachesolr@solr:current_search:redcat_adaptivetheme:u.0:http://amodi.localhost.edu/d7.redcat.org/user                     |
| facetapi:apachesolr@solr:current_search:redcat_adaptivetheme:u.145:http://amodi.localhost.edu/d7.redcat.org/                       |
| facetapi:apachesolr@solr:current_search:redcat_adaptivetheme:u.145:http://amodi.localhost.edu/d7.redcat.org/search/content/music   |
| facetapi:apachesolr@solr:current_search:redcat_adaptivetheme:u.145:http://amodi.localhost.edu/d7.redcat.org/users/admin            |
| facetapi:dozpu2qmsxe9KZXUOE4XADpSrvJG8PyQ:redcat_adaptivetheme:u.0:http://amodi.localhost.edu/d7.redcat.org/search/content/music   |
| facetapi:dozpu2qmsxe9KZXUOE4XADpSrvJG8PyQ:redcat_adaptivetheme:u.0:http://amodi.localhost.edu/d7.redcat.org/theater                |
| facetapi:dozpu2qmsxe9KZXUOE4XADpSrvJG8PyQ:redcat_adaptivetheme:u.0:http://amodi.localhost.edu/d7.redcat.org/user                   |
| facetapi:dozpu2qmsxe9KZXUOE4XADpSrvJG8PyQ:redcat_adaptivetheme:u.145:http://amodi.localhost.edu/d7.redcat.org/                     |
| facetapi:dozpu2qmsxe9KZXUOE4XADpSrvJG8PyQ:redcat_adaptivetheme:u.145:http://amodi.localhost.edu/d7.redcat.org/search/content/music |
| facetapi:dozpu2qmsxe9KZXUOE4XADpSrvJG8PyQ:redcat_adaptivetheme:u.145:http://amodi.localhost.edu/d7.redcat.org/users/admin          |
+----------------------------------------------------------------------------------------------------------------------------------+

With per role per page:

mysql> select cid from cache_block;
+------------------------------------------------------------------------------------------------------------------------------------+
| cid                                                                                                                                |
+------------------------------------------------------------------------------------------------------------------------------------+
| facetapi:apachesolr@solr:block:bundle:redcat_adaptivetheme:r.1:http://amodi.calarts.edu/d7.redcat.org/                             |
| facetapi:apachesolr@solr:block:bundle:redcat_adaptivetheme:r.1:http://amodi.calarts.edu/d7.redcat.org/search/content/music         |
| facetapi:apachesolr@solr:block:bundle:redcat_adaptivetheme:r.2,3,4:http://amodi.calarts.edu/d7.redcat.org/search/content/music     |
| facetapi:apachesolr@solr:current_search:redcat_adaptivetheme:r.1:http://amodi.calarts.edu/d7.redcat.org/                           |
| facetapi:apachesolr@solr:current_search:redcat_adaptivetheme:r.1:http://amodi.calarts.edu/d7.redcat.org/search/content/music       |
| facetapi:apachesolr@solr:current_search:redcat_adaptivetheme:r.2,3,4:http://amodi.calarts.edu/d7.redcat.org/search/content/music   |
| facetapi:dozpu2qmsxe9KZXUOE4XADpSrvJG8PyQ:redcat_adaptivetheme:r.1:http://amodi.calarts.edu/d7.redcat.org/                         |
| facetapi:dozpu2qmsxe9KZXUOE4XADpSrvJG8PyQ:redcat_adaptivetheme:r.1:http://amodi.calarts.edu/d7.redcat.org/search/content/music     |
| facetapi:dozpu2qmsxe9KZXUOE4XADpSrvJG8PyQ:redcat_adaptivetheme:r.2,3,4:http://amodi.calarts.edu/d7.redcat.org/search/content/music |
+------------------------------------------------------------------------------------------------------------------------------------+

cpliakas’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for testing! Committed at 59e8347.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

webavant’s picture

Version: 7.x-1.x-dev » 7.x-1.0-rc4
Status: Closed (fixed) » Active

Facets 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.

cpliakas’s picture

Status: Active » Closed (fixed)

Facets are losing still display elements for me when block caching is enabled.

This 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.