Can you please explain How to modify the theme to get authcache to work?
I'm sorry if this is an obvious question for everyone else.. but I can't figure out how to do this. I am very new with Drupal and need cache set desperately, since my pages for loged in users are loading very slow. Any help with instructions would be great. :)


Ela’s picture

Anyone? :)

Jonah Ellison’s picture

The first step is to look at all your user-customized content on your website. You'll either need to make exclude these pages from the cache or setup up special caching for them. The number one rule is: the final HTML must be exactly the same for every user for cached pages.

For example, displaying "You are logged in as [username]" is a user-specific piece of content. You'll need to modified in your theme for this. Open up page.tpl.php (or wherever the phrase is stored/generated, maybe template.php) and either remove it or change it. Authcache has two theme variables for you to use for this instance: $user_name to display the logged-in user name and $user_link to display the name linked to their profile (both work for cached and non-cached pages). So you could change it to: You are logged in as <?php print $user_name ; ?>

Caching is a rather advance concept, so don't feel bad if this doesn't all come to you at once. You'll probably have to experiment. Let me know if there is something more specific I can explain. You may also want to move to a more powerful host first since a lot of time will probably be involved to make Authcache work the way you want it to.

Ela’s picture

Thank you for your reply :)
I will follow your advice.
Is there anything that I MUST add to page.tpl.php for it to get cached?
Meaning.. will adding the code you provided above get pages cached?
When I first installed this module following the instructions provided, the pages were not getting cached and the information shown on pages was " "Page not cached."
Thank you again for your help.

Jonah Ellison’s picture

Status: Active » Closed (works as designed)
paulinewu’s picture

Status: Closed (works as designed) » Active

Hi, I have a question specified for using the "$is_page_authcache" variable.

The instructions say: $is_page_authcache is set to TRUE in all template hooks if the page is to be cached.

Suppose I want the entire site to be cached, does this mean ALL template hooks must have this variable set to true? If so, how is this variable used? Is there an example of how this variable is used?

Thanks in advance.

simg’s picture

Status: Active » Closed (works as designed)

>Suppose I want the entire site to be cached, does this mean ALL template hooks must have this variable set to true?

No, aside from pages that are specifically excluded from caching in the authcache admin settings (admin/*, user/* etc) the entire site is cached. you don't need to do anything else unless you want "per user" personalised content.

some of the per user customisation can be handled by straightforwardly by authcache ajax block loading, some may have to be handled by creating your own authcache - ajax modules.

blueblade’s picture

hmmm...sorry Im a little confused. So what exactly should we do to the tpl.php pages? how exactly do we set $is_page_authcache to true?

simg’s picture

>So what exactly should we do to the tpl.php pages?

That depends on what you're trying to achieve. Quite possibly nothing ...

What you *can't* have in your templates is any kind of "per user" customisation. So if you have any, it needs to be removed.

You don't set $is_page_authcache, Authcache does. You can use it in your templates as a read-only value to know whether or not Authcache is going to cache that particular page or not. (I think this would imply somewhat advanced use of Authcache though).

If you want per user customisation (ie different output for different users) this must be included in blocks which then get loaded via a second ajax call after the main page has loaded (Personally, I'm not thrilled about this functionality, but that's how it currently works).

Authcache adds a "load block via javascript" checkbox in the block admin page to make this easy OR if that doesn't do what you need, there is the possibility of writing your own modules that attach themselves to the javascript call back.

Worth noting, I'm not the original author of this module, I just made the D7 port for my own purposes. I haven't actually needed to build any Authcache sub-modules (ie found someone to sponsor the development) so I may be a little hazy on the exact process

blueblade’s picture

Thanks for your prompt reply...I have a very simple question here tho: what should I change in

$conf['memcache_servers'] = array('localhost:11211' => 'default');
$conf['cache_backends'][] = 'sites/all/modules/memcache/';
$conf['cache_backends'][] = 'sites/all/modules/authcache/';
$conf['cache_class_cache_page'] = 'MemCacheDrupal';

so that authcache can work on my site?

I copied that into my setting.php file and all I get is a blank page with an error message:

Fatal error: Call to undefined function lock_acquire() in /home/admin/domains/ on line 935

simg’s picture

It would be very helpful if you have a new question if you were to create a new issue for it in the queue.

blueblade’s picture

never mind. I switched to filecache and everything is working fine now =) thanks for your help.