I am maintaining a website which makes use of a node access module. This means that Drupal's block caching is not available.
Unfortunately Superfish was identified as a performance drag during a performance audit (3 menus on the site, around 180ms - 220ms render time per menu).
This isn't an issue for anonymous users as they can take advantage of page caching or an external cache such as Varnish - but authenticated users are stuck with half a second of menu rendering per page load.
I've written a patch to introduce caching in superfish_block_view(). I understand it is unlikely to be accepted, but at least if anyone else encounters this issue they can apply the patch themselves.
Comments
Comment #1
nicksanta commentedPatch attached.
Comment #2
nicksanta commentedRan into an issue with this patch where the active trail was part of the cached data and was causing the wrong part of the menu to be expanded when serving the cached version.
Rerolled patch attached.
Comment #3
Anonymous (not verified) commentedHi,
I was searching for a way to cache superfish and tried this patch. It gives a boost...., only not with i18n: there is no language change: the first language is only visable.
Q: There is this module "Block Cache Alter" with a few more cache options. Block cache alter does work with a lot of blocks, but doesn't work together with superfish. Could Block Cache Alter be a solution for caching a superfish block in stead off a sf?
Comment #4
Anonymous (not verified) commentedWe solved caching of superfish menu with a patch for Block Cache Alter, see https://www.drupal.org/node/1562700#comment-8949471.
We used Block Timer (sandbox) https://www.drupal.org/sandbox/jchin1968/2061005 to measure the block timings.
Our menu, content generated by taxonomy menu and with counting of nodes per menu link (total +/+ 4700 nodes), rendered by superfish has a render time of 1250 ms withouth caching. With Block Cache Alter: 0ms.
Comment #5
m.lebedev commentedSubscribe. #3, i18n. Using Blockcache_alter could not solve the problem of caching.
Comment #6
m.lebedev commentedThis problem was solved by using the module cachedblock. It supports multiple languages.
Comment #7
torgospizzaPatch in #2 needs work. With multiple users hitting the site at the same time, there exists the possibility that some users will see other users' menu items (for example if you are building a custom menu where one of the links is the logged-in user's username).
I am able to use block caching on our site so perhaps that is the reason, but that scenario should also be taken into consideration for the next iteration of this patch.
Comment #8
alexp999 commentedI was trying to get to the bottom of why our pages where taking 3 seconds to load, it was primarily down to the menus.
We have taxonomy menus and taxonomy menu active trail, so couldn't cache globally.
I just installed the Block Cache Alter module and overrode the cache for the superfish menu (and our other menus), to per page.
Works perfect, after the first visit to a page the block is cached and re-visited pages now only take about 1 sec to load :)
Comment #9
lobsterr commented