I'm trying to get the Drupal5 version of this module to work in order to display dynamic content to anonymous users that comes from a node with content type php. This doesn't work.
Stepping through the code with a debugger, I can see that function cacheexclude_init() correctly identifies my path to be excluded and sets $GLOBALS['conf']['cache'] = FALSE;

However, the page is still added to the cache, so the next time cacheexclude_init is called, it is already to late, as this is being called from these lines in _drupal_cache_init in bootstrap.inc:

  elseif ($phase == DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE) {
    if ($cache = page_get_cache()) {
      if (variable_get('cache', CACHE_DISABLED) == CACHE_AGGRESSIVE) {
        drupal_page_cache_header($cache);
        exit();
      }
      elseif (variable_get('cache', CACHE_DISABLED) == CACHE_NORMAL) {
        require_once './includes/module.inc';
        bootstrap_invoke_all('init');
        drupal_page_cache_header($cache);
        bootstrap_invoke_all('exit');
        exit();
      }
    }
    require_once './includes/module.inc';
  }

bootstrap_invoke_all('init'); will call the function cacheexclude_init, but at this point the cached page is already being served.
So as far as I understand this, $cache = page_get_cache() would need to fail in order for this to work. I'm just starting to look at this code and I guess the page should never have been added to the cache in the first place due to the cacheexclude module.
I have cleared the cache and modified the node in question. Caching is set to normal.

What am I doing wrong here? Is the CacheExclude module is known to be working for my use case?
Any help would be appreciated.

Comments

Bodo Maass’s picture

One further observation: If I add

$GLOBALS['conf']['cache'] = FALSE;

directly to the PHP content that I want to exclude from the cache, it works as expected (completely without using this module).

Crell’s picture

CacheExclude requires that the page you are excluding not already be cached. If it is, it won't clear it for you. Try flushing your page cache first. The D5 version does not do per-node-type filtering, only per-path. So make sure that the path you have configured is accurate.

Also note that the Drupal 5 version is not really maintained at this point, as the focus is on the Drupal 6 version.

Bodo Maass’s picture

Hi Crell,

Thanks for your answer. I don't expect the D5 version to be maintained, but this is a production site that cannot be upgraded yet. I just wanted to confirm that the D5 version of the module is known to be working.

I did flush the cache and modified the node in question. I entered the alias of the node in the cacheexclude settings. Do I also need to enter the normal path (in the form node/123) ?

Bodo Maass’s picture

I guess this was it. I cannot use the alias, but must enter the node path of the node in question. That wasn't really clear from the documentation.

Crell’s picture

I think that changed later on in the Drupal 6 version. I suppose you could try backporting 6.x-2.1, as it does have a couple of fixes along those lines. The patch to add alias support was quite trivial.

Crell’s picture

Status: Active » Closed (fixed)