[Solved][Drupal] Boost not saving html for a drupal page

| | 2 min read

Boost is one of the most widely used Drupal modules designed for static page caching. It creates html files for Drupal pages.When an anonymous user visits the page for the first time, boost generates an html page and then serves the html directly to the other anonymous users of the site, till the page cache expires, which increases the performance of the site for anonymous users, as everything is handled at the Apache level. Nevertheless, there will be situations where boost might not cache a page. Read on to know if you have faced a similar problem.

In Drupal 7, Boost will create the static html file for a page using hook_exit(). Using this, it performs various checks to see whether the page is cacheable or not, and if it is cacheable, create an html file for it in the boost cache directory.

We found a strange issue in one of the projects that we were working on. Boost was not saving the html for drupal pages, even if those pages were cacheable. On debugging, we figured out that, for all pages, the function () returns false, and the application returns from hook_exit without creating the html page.

Finally, we reached the code where drupal_page_is_cacheable is set to false. In the session.inc Line 254, it checks to find out whether the current user is an authenticated user or $_SESSION is set, and if any of these are true, it sets the drupal_page_is_cacheable to false.

In our case, the $_SESSION was the culprit. The $_SESSION is set for anonymous users in our custom code, which caused this issue. We cleaned up the code to avoid the use of $_SESSION for anonymous users, and the boost started working fine. You can of course use the debugging workflow that we have explained above to see the problem.