# Help kill ghost request

**URL:** <https://www.ruby-forum.com/t/help-kill-ghost-request/171569>\
**Category:** Rails\
**Created:** [July 5, 2009, 9:33pm UTC](https://www.ruby-forum.com/t/help-kill-ghost-request/171569 "2009-07-05T21:33:55Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [July 5, 2009, 9:33pm UTC](https://www.ruby-forum.com/t/help-kill-ghost-request/171569/1 "2009-07-05T21:33:55Z")

</div>

I’ve been troubleshooting a problem with my captcha and finally figured  
out that any time I make one request to my localhost server, it receives  
and processes two requests, for example if i got to  
localhost:3000/users/test this shows up in my log:

This is really tripping up my captcha (which used to work) it renders  
the image from the first request, but will only accept the characters  
from the second request. I have reproduced this problem with a sample  
rails app, and one other application, so it looks like a possible  
problem with my rails install, possibly a path problem? I also tried  
restarting my computer, just incase, but it didn’t help. This is totally  
alien to me, if anyone has any troubleshooting tips please let me know,  
it is a little difficult for users to fill out a captcha, if the  
characters in the image are wrong.

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [July 5, 2009, 9:35pm UTC](https://www.ruby-forum.com/t/help-kill-ghost-request/171569/2 "2009-07-05T21:35:16Z")

</div>

Link to pastie:

[http://pastie.org/534977](http://pastie.org/534977)

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [July 6, 2009, 4:20am UTC](https://www.ruby-forum.com/t/help-kill-ghost-request/171569/3 "2009-07-06T04:20:15Z")

</div>

On Sun, Jul 5, 2009 at 12:33 PM, Richard  
Schneeman[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve been troubleshooting a problem with my captcha and finally figured  
> out that any time I make one request to my localhost server, it receives  
> and processes two requests

Without seeing all of the code, it’s only a WAG, but I’d bet your first  
request is from loading the page, and the second is being triggered  
by a JS onload (or domready, or somesuch) event somewhere.

## Maybe you could make available a small test app that demonstrates the problem?

Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [July 6, 2009, 11:25pm UTC](https://www.ruby-forum.com/t/help-kill-ghost-request/171569/4 "2009-07-06T23:25:10Z")

</div>

Hey hassan thanks for the reply, It looks like the problem isn’t with  
my server, seeing two requests, that is normal for my localhost and for  
my sites on dreamhost. However it doesn’t mean that my captcha problem  
went away…it took a little while to get up and running, but here is a  
hosted demo of the problem:

[http://snowmaninthesun.dreamhosters.com](http://snowmaninthesun.dreamhosters.com)

Here is the complete source code to the demo (its a simple rails app  
with the simple\_captcha plugin and some scaffolding):

[http://github.com/snowmaninthesun/captchaProblemDemo/tree/master](http://github.com/snowmaninthesun/captchaProblemDemo/tree/master)

If you go to [http://snowmaninthesun.dreamhosters.com](http://snowmaninthesun.dreamhosters.com) , the first time  
you enter the captcha it doesn’t work…every time after that it will  
work. More information on the problem is listed at the site. This is  
different from what i’m seeing at my other site  
[http://www.uniteddictionary.com/new\_slang](http://www.uniteddictionary.com/new_slang) . Which will sometimes work,  
and sometimes not, unlike this demo which seems to fail consistently.  
Let me know if you have any ideas as to what may be causing this problem

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [July 7, 2009, 2:00am UTC](https://www.ruby-forum.com/t/help-kill-ghost-request/171569/5 "2009-07-07T02:00:14Z")

</div>

In some browsers, the following tag will result in a second request to  
the  
server:

![]() I would look for situations where a blank image/js  
file/css  
file, etc… would be loaded.

On Sun, Jul 5, 2009 at 10:19 PM, Hassan S. \<

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [July 7, 2009, 1:57am UTC](https://www.ruby-forum.com/t/help-kill-ghost-request/171569/6 "2009-07-07T01:57:54Z")

</div>

On Mon, Jul 6, 2009 at 2:25 PM, Richard  
Schneeman[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> If you go to [http://snowmaninthesun.dreamhosters.com](http://snowmaninthesun.dreamhosters.com) , the first time  
> you enter the captcha it doesn’t work…

mmm – actually, it worked for me the first time: OS X/FF3.0.11 with  
the Firebug net console open to watch the interaction. No prob.

Ain’t that always the way? 🙂

## I’ve got to run off to do something else now, but will try to take a look at the code later, maybe I can reproduce locally.

Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [July 7, 2009, 2:19am UTC](https://www.ruby-forum.com/t/help-kill-ghost-request/171569/7 "2009-07-07T02:19:59Z")

</div>

Thanks for this info hassan “OS X/FF3.0.11” i tried it in safari, it  
worked great…i tried checked my version of firefox its 3.0.11, and i’m  
running OS X…so what could be different???

I realized that i have YSlow set to autorun, when i turned that off and  
visited my previous posted link it magically works…that would explain  
why it previously worked, but quit. OMFG i’ve lost about a day of my  
life due to an “optimization” plugin. In retrospect it seems so obvious,  
thanks for your patience, and double checking. I’m in the process of  
making sure the YSlow developers are aware of this potential situation,  
but the obvious immediate fix is to turn off YSlow.

I started teaching myself rails about 2 years ago, and if it wasn’t for  
this forum, i would have given up long ago, so thanks for bearing with  
me!!

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [July 7, 2009, 2:11am UTC](https://www.ruby-forum.com/t/help-kill-ghost-request/171569/8 "2009-07-07T02:11:55Z")

</div>

Some browsers including firefox (i believe)

---

<div class="post-metadata">

**Author:** ![indigoi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/b3f665/32.png) [@indigoi](https://www.ruby-forum.com/u/indigoi)\
**Post date:** [July 7, 2009, 3:08am UTC](https://www.ruby-forum.com/t/help-kill-ghost-request/171569/9 "2009-07-07T03:08:35Z")

</div>

On Mon, Jul 6, 2009 at 5:19 PM, Richard  
Schneeman[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I realized that i have YSlow set to autorun, when i turned that off and  
> visited my previous posted link it magically works…that would explain  
> why it previously worked, but quit. OMFG i’ve lost about a day of my  
> life due to an “optimization” plugin. In retrospect it seems so obvious,  
> thanks for your patience, and double checking. I’m in the process of  
> making sure the YSlow developers are aware of this potential situation,  
> but the obvious immediate fix is to turn off YSlow.

Good find, and thanks for reporting it!

–  
Hassan S. ------------------------ removed\_email\_address@domain.invalid  
twitter: @hassan
