I am trying to clear the page cache of drupal as micro invasive as possible by using Cache Expires and custom logic. On each page, the menu is shown down to Level 2 in a footer and a hover area. Therefore I did only rebuild all menu trees and remove pages from cache if an item on the second or first menu level has been changes.

Now we have got an additional menu for mobile devices which is load with each page and shows down to four menu levels. Changing a menu on the first to fourth level would no lead to a clear of almost any pages.

To avoid this, it would be great to put all that menu stuff out of the page html and put in a single file, containing just the menu information in e.g. json format. So if a menu changes I would only need to update the menu file and the changed node.

Are there any smart hacks out there or even modules dealing with that?


There are several ways to achieve this - maybe more.

  1. Ajax call and include the menu via jquery / javascript from drupal at runtime

  2. Ajax call and iclude the menu via jquery / javascript from a static generated file by cron

  3. SSI or ESI include at proxy level of a static file generated by cron

At the moment my favorite is 2. Option as the First option has a major performance drawback because the menu has to be generated for each page visit

Number 2. and 3. inlcude the menu within under 10 milliseconds but 3. would be perfect as it makes the least problems with SEO. As I do not yet have nginx as reverse proxy available in production I stick at 2. as I could not get to work SSI and PHP with apache and php virtual() is not cached by the drupal page cache (in fact it breaks it)

There is a module which helps with SSI and ESI called https://www.drupal.org/project/esi

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.