So your web app double posts?

This post is just in case I forget this again in the future. Hopefully, I'll find it when I search the net for this issue.

This post is testament of my tenacity (more like my stupidity when I let myself get mentally exhausted).

I have been working on integrating some Mojolicious apps into our existing Apache CGI/mod_perl set of applications. When I went to test the latest version of a particular app, that changed how things were added, I decided to put some warn statements in to see if I had the flow right. Looking in the error log, I started seeing everything happening twice!

The methods that get used to create the initial view. The methods that get used to add a new item and subsequently view it. Everything.

I walked through my app and couldn't find any obvious reason for the odd behavior. I double-checked my templates but found nothing. I spent the better part of two hours searching the net, looking at the Mojolicious docs, Apache docs and tweaking my Apache config. All because I was sure that was where the problem resided; after all, Mojolicious wasn't originally intended to be used that way.

At the two hour mark, I asked a few people if they had any ideas. We walked through the same things again together and yet found nothing that should cause this weirdness.

I then put some warns in some of our mod_perl apps only to find the same thing was happening there as well.

I added a new CGI script that did nothing but print a content-type, warn "hello\n" and print "hi\n". When I accessed it, sure enough, I saw "hello" in the error log twice.

I switched the server I was working on, thinking that surely something was just really wrong with my Apache install on the server. Nope, I saw the same exact behavior.

I had my co-worker access my sandbox and the warns were only showing up once. Lightbulb time!

I refined my search and found that someone had the same sort of problem with Firebug a while back. I looked at the status bar and found that Firebug was disabled... but YSlow was enabled.

I disabled YSlow and restarted Firefox. I accessed the pages and sure enough, the warns all showed up once. For extra validation, my co-worker enabled YSlow and hit the pages. The warns did indeed happen twice for her.

So if you use YSlow, turn it off when you are not actively testing page loads or you too might spend a stupid amount of time tracking down what amounts to the intended behavior of a browser add-on. (YSlow loads the page once using the cache and once without so that it can compare the two.)


That must have been a frustrating row.

Leave a comment

About Mr. Muskrat

user-pic I'm married with 2 girls. By day, I work as a Senior Design Engineer (full time Perl programmer) for EFJohnson Technologies, a Land Mobile Radio company, in the Dallas/Fort Worth area. By night, I play various games as the mood strikes me. (Lately it's CPAN smoke testing.)