I have cache exclude set to exclude our home page so as to allow for a random video to be played each time the page is loaded. It has worked well for quite some time. For some reason, we have started to get a "page not found" error on the home page (although all other pages appear to be working properly). As soon as I removed the exclusion, the home page started working for anonymous users again.

Comments

Ludovik’s picture

Priority: Normal » Major

Hi.

I have the same problem. I set to exclude my home page. Does anyone know what to do?

This is what appears on the home page for the anonymous users since I installed Cache exclud: "The page you requested does not exist. For your convenience, a search was performed using the query 403 shtml."

Crell’s picture

Status: Active » Postponed (maintainer needs more info)

I have no idea what that error message means. All this module does is toggle the global cache variable off. I don't know how it could possibly cause pages to not exist unless you have something else going on.

fandreatta’s picture

Hi Crell,

We faced a very simmilar issue on a site of ours. We realized that, when cacheexclude executes the hook_init, it validates whether the current node should be cached or not, by checking its type. The following code shows that:

// Check if the current node type is one we want to exclude from the cache.
if ($node = menu_get_object('node')) {
  $types = array_filter(variable_get('cacheexclude_node_types', array()));
       
  if (in_array($node->type, $types)) {
    $GLOBALS['conf']['cache'] = 0;
  }
}

But, on a custom module, when a menu item is defined using the hook_menu, and the access callback is a function declared in a separated file (probably loaded on hook_init), the execution of menu_get_object('node') tries to identifies the permission of this item before loading the file that declares the access callback function.
Is is possible to validate if the current path is a node before executing the menu_get_object('node') call?

Thanks very much
-- Fábio --

Crell’s picture

Ugh. That issue. I don't know of a way around it, I'm afraid. That's a design flaw in Drupal 7. The only thing I can think of is to not use menu_get_object() but use arg() instead, but I don't even know if that would work and I refuse to use that crime against nature in a module. :-)

m4olivei’s picture

Hello,

We had this issue as well. We were excluding only the home page and found that the 404 response somehow got by the cacheexclude rule and got cached. Sounds like the exact circumstance OP had and @fandreatta. I don't understand the comment in #3 though, it's not making sense to me, as for the homepage, in cacheexclude_init() it should match the first if statement, set cacheable to FALSE and return. How can the homepage possibly get cached as 404 here?

In our case, I was able to refactor so that we no longer had to exclude the homepage and I could turn off cacheexclude. Then the issue went away (at least I hope) after that.

Thanks,
Matt

Crell’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (won't fix)