Awesome module, great work, and cannot believe more sites aren't using it.

I have a fairly edge case scenario in which I use Shibboleth Authentication on my site. Esssentially, if very specific conditions are set up with Shibboleth server headers, we don't want the page to be cached, but the only way (I think) to get that to work through your module would be to have the definitions of PHP, whereas for 99% of the site, paths would perfectly.

I've come up with a solution whereby the shib_auth module's weight is set to less than authcache. This works perfectly, however, we're consistently getting lower page load/RPS responses due to the extra stuff that shib_auth does in shib_auth_init.

Ideally, I'd like you to throw a drupal_alter from authcache_init on line 152, something like:

  $_authcache_info = array();  
  $_authcache_is_cacheable = _authcache_is_cacheable();

  // new line:
  drupal_alter('authcache_is_cacheable', $_authcache_is_cacheable);

  if ($_authcache_is_cacheable) {
    global $conf;

Failing that, another solution would be to allow other modules to alter the global $_authcache_is_cacheable, and the call to _authcache_is_cacheable() to honour what I could then set $_authcache_is_cacheable to outside of a module_hook, therefore enabling authcache still to run before shib_auth therefore with no loss of speed :-) Something like:

function _authcache_is_cacheable() {
  global $user, $_authcache_debug_info, $is_ajax_authcache, $_authcache_info, $conf;
  // Do not cache if...
  if(!empty($_authcache_info['no_cache_reason'])) {
    // assume someone else has filled this
    return FALSE;

  if (!empty($_POST)) {
    $_authcache_info['no_cache_reason'] = 'POST request';
    return FALSE;

That way I could add code into my module outside of any hook of

$_authcache_cacheable = FALSE;
$_authcache_info['no_cache_reason'] = 'My reason';

and it wouldn't all be overwritten by line 84 of helpers.inc, setting $is_cacheable = TRUE;

Do either of these sound like reasonable solutions to the request?



simg’s picture

busy at the moment, will give this some thought.

in principle it seems like a good idea.

znerol’s picture

I'd suggest introducing a drupal_alter.

znerol’s picture

Status: Active » Fixed

I've pushed a backport from the 7.x-2.x branch onto 7.x-1.x dev. You may now implement hook_authcache_request_exclude in a custom module. If you want to exclude the page request, just return a translated string giving the reason. From the docs:

 * Exclude a page from being cached based on the request.
 * @return A translated string specifying the reason of exclusion or null.
function hook_authcache_request_exclude() {
  if (aceajax_is_aceajax_request()) {
    return t('Authcache Ajax request');
kpa’s picture

Sorry for the tardiness in response to this - been a busy couple of weeks.

This looks awesome though, exactly what I needed :-)

Thanks very much!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.