captcha module [version 5] leads to increase the query

navaneeth's picture

We have News site with lots of hits per day. So we are decided to optimize the code for anonymous user. We logged the query list of all pages, then we confirmed that all pages are retrieved from performance cache except the node page. The same bunch of queries repeated twice in the node page. In our node page we have some custom blocks, node comments and captcha.
Then I take the following steps to find the cause.
Removed the block from the node page --- No improvement
Enabled the block to the node page and disabled the comment module ---- No improvement
Enabled the block and comment module , Disabled the captcha ------ There is the great improvement.

So i realized that there is some performance issue in captcha. I analyzed the captcha.module file and find the cause. In line 505 [$captcha = module_invoke($captcha_point->module, 'captcha', 'generate', $captcha_point->type);] causes the query repeating. This line is to generate the captcha. Please look at the issue and help me to get alternate solution. I also try to fix the issue.

Comments

I noticed the same thing

eli's picture

I noticed the same thing using MyCaptcha on Drupal 5. I ended up just hacking it... There's no reason to regenerate a new CAPTCHA question for each visitor if the previous visitor didn't even attempt to answer it!

If you're interested, I can dig up the code on monday.

Missing CAPTCHA image

adavis.co.uk's picture

I had a quick look but didn't see a similar issue. Sorry. Yes, I'd really appreciate your hack. Thanks.

see here

Captcha and Page cache

Shyamala's picture

If we have Captcha enabled. Page cache doesn't work on pages with Captcha. The bootstrap runs twice for every page load and hence the number of queries on a Captcha page is twice as much!

Is there any way to call and refresh captcha without having to do a Bootstrap?

Netlink Technologies Ltd
I blog and Twitter :)

Yes, the module breaks page

eli's picture

Yes, the module breaks page caching on purpose. I'm not really sure why, since it doesn't matter how many anonymous users get the same CAPTCHA so long as it changes once someone tries to answer it.

We're using MyCaptcha with the attached patch.

My Captcha is not working

ramucd's picture

Hi
My captcha is not working when i applied this patch. Any Suggesstions

High performance

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week