Browser sending multiple requests at once!
So I was working on me project early this morning (was working on it almost a day actually), when I encountered a unique problem (well, this is the first time I encountered it).
I was testing email notifications using sendmail. It works but the problem is it is sending multiple emails. I was like What the F***? It sent almost three emails notifying me about my account. Fortunately Gmail is ignoring my fake emails since the more often you read the message the less likely it is spam.
Enough with the story. What the hell is happening?
So let me explain first how a ‘browser request’ works. At least to my feeble mind’s point of view. If you feel you’re an expert feel free to correct me on the comments.
Whenever you create a request to the server, which is basically typing the website address on the browser’s address bar and hitting enter, the request is sent to the website’s server. In turn, it will also send requests from <image>, <script>, <style> tags and all other bunch of tags that has “http://this_is_a_stickup.com” as the value for their attributes.
So whenever a browser encounters something like that above, it simply creates another request to the website. If the src=”” attribute for example is empty it will most likely create a request to the current page. Thus, creating another request. You can check it out using web developer tools in modern browsers. I caught mine using the Web Console in Firefox.
How can we avoid/fix this?
Seriously? Ok, if you insist, how about hunting down those empty attributes filling them with values?