4

The Cache Router module advertises that it "has an option to utilize the page_fast_cache part of Drupal in order to reduce the amount of resources needed for serving pages to anonymous users."

However, the only Google hits for "drupal page_fast_cache" point back to cacherouter.

What is page_fast_cache?

1 Answer 1

4

I believe the project page is referring to page_cache_fastpath(), which is called during Drupal bootstrap from the following code:

if (variable_get('page_cache_fastpath', FALSE) && page_cache_fastpath()) {
  exit;
}

The documentation page reports the following description for the function:

By implementing page_cache_fastpath(), a special cache handler can skip most of the bootstrap process, including the database connection. This function is invoked during DRUPAL_BOOTSTRAP_EARLY_PAGE_CACHE.

The example code reported in that page helps to understand how the function needs to be implemented, and what should do.

function page_cache_fastpath() {
  $page = mycache_fetch($base_root . request_uri(), 'cache_page');
  if (!empty($page)) {
    drupal_page_header();
    print $page;
    return TRUE;
  }
}

If the module reports to utilize it, it means it actually defines the page_cache_fastpath() function, which is called by Drupal core code.
To notice that it's not a hook, but a function. This means that a module called "mycache" doesn't need to implement mycache_page_cache_fastpath(), but page_cache_fastpath(). In fact, the bootstrap code is explicitly calling page_cache_fastpath(), as it is evident in the code I reported at the beginning of this answer.

2
  • Looks like a very promising lead, thanks. Keeping the Q open until I work out if that's really what they mean :) May 25, 2011 at 10:13
  • 1
    Yes, Kiam's answer is correct. It skips the database connection - obviously this only works if your cache_page bin is backed by some non-database storage (such as Memcached or APC).
    – Dylan Tack
    Jul 5, 2011 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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