Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
Ludovik CreditAttribution: Ludovik commentedHi.
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."
Comment #2
Crell CreditAttribution: Crell commentedI 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.
Comment #3
fandreatta CreditAttribution: fandreatta commentedHi 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:
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 --
Comment #4
Crell CreditAttribution: Crell commentedUgh. 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. :-)
Comment #5
m4oliveiHello,
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
Comment #6
Crell CreditAttribution: Crell at Palantir.net commented