DRUPAL7 Boost module provides caching for logged-in users

Source: Internet
Author: User
Tags drupal

This time study DRUPAL7 cache related, read a lot of information, all mention the boost and Authcache two modules, today for a boost.

Specific download installation, configuration, etc., written on the official website to listen clearly, boost module address, installation Configuration method: Boost Handbook for Drupal 7.x

Xi ' An building talk about the principle of boost, it itself only for anonymous users to provide caching, because anonymous users see the page is consistent, the cache is also very simple and rude, but also very efficient, is directly into the HTML static page as a cache, the next visit, do not go to drupa a lot of flow, If the cache is hit, the static page is returned directly, isn't it cool? Is it quicker to return to an HTML page without having to access a series of functions and databases? (Of course, some of the functions associated with the Boost module and some of the drupal necessary functions are still going to go, since boost will, after all, depend on the URL and the user role to determine whether to cache the page, etc.).

But I want to let it on the user has also played an effect, how to chew a half-day source, found:

/** * Implements hook_boost_is_cacheable (). * * TODO Support for node types, etc. * * @param $parts * info on this  Request * @param $request _type * If the request_type is ' status ', we assume that's being * called from the admin Status Block. Since the user must is * logged in to view this block, and we do not return false. * * @return $parts*/functionBoost_boost_is_cacheable ($parts,$request _type= ' normal ') {  Global $user; if($user->uid! = 0 &&$request _type! = ' status ') {//focus!!! $parts[' is_cacheable '] =FALSE; $parts[' is_cacheable_reason '] = ' Boost only works for anonymous users. '; }  Else {    $parts[' is_cacheable '] =TRUE; } debug (' 1 '); return $parts;}

See, because there is hook_boost_is_cacheable () This hook, so, boost in determining whether to cache this page, the role of the code is based on this, of course, the role is only a judgment of the dimension, But it's enough for my needs. Direct modification to determine the condition is:if ($user->uid! = 1 && $request _type! = ' status ').

Why is it modified to "$user->uid!" = 1", because 1 refers to the Super administrator, there is no need for single-digit level of people to add the cache, wasting hard disk resources, no meaning. Excluding the Super administrator, the rest of the role is anonymous and registered users , is not very cool?

Of course, some people will ask, that different roles, see the page content is certainly different ah, even if the cache, also does not meet the " different people browse , see different information" the actual demand ah.

So far, my current solution is to use a module: Ajaxblocks, through which different block blocks are loaded through Ajax, so that different roles get different information to the backend to the block processing.

However, there is a problem, there is no data cache, this requires Memcache module, but I have not studied, and then to fill it up.

How about the feasibility of my solution? I hope everyone's advice ~

DRUPAL7 Boost module provides caching for logged-in users

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.