24 January 2011

Browser send same request twice or multiple times

Here at Planbox, we had a problem on a page where the browser was making the same request multiple times. In Firebug we saw something like this:

  • GET page
  • GET jquery-ui.js
  • GET page.css
  • GET page
  • GET loading.gif
  • GET page

Looking at the HTTP request headers, I noticed the 1st call was accepting text/html but the 2nd and 3rd calls were accepting image/*.

So I googled and found this article from Michael Morton. Other articles also touch on the subject but these are potential causes:

  • Empty src attribute on an img tag
  • Empty url definition on a CSS property
  • Empty href attribute on an a tag.

It had to be one of those. So I opened up Notepad++ and started searching and didn't find anything.

Then my colleague Seb suggested I used jQuery to find it. Of course! So here's a quick code snippet to find bad tags. Just run this in the console of Firebug.


In a snap I found the culprits. They were a couple of Javascript functions generating img tags on the fly but leaving the src attribute empty.

comments powered by Disqus