Today we inherited on a multi-tenant Rails app for a new client that had a weird bug. Every
GET request that was made in the application showed up twice in the l:low_brightness:
1 2 3 4 5 6 7
As you can clearly tell from those two requests - Rails thinks the two requests are in different mime types,
HTML and the general
styleheet_link_tag are protected against empty requests - we narrowed it down to
image_tags - but it seems that if you pass an empty string or a
nil value to
image_tag - no request is being made.
So who is to blame?
When all else failed, we decided to break down the app views one by one. Luckily the perpetrator was one of our first suspects. Friends, meet favicon_link_tag.
favicon_link_tag simply creates the HEAD section link tag to point to the favicon asset, and in the case of having no favicon address specified - the browser makes a request to the current url and that’s where the extra request in our logs comes from.
List of possible causes for repeating requests in the rails logs
- Manual AJAX requests without some kind of
e.preventDefault(), They’ll run, but the original link role is still going to kick in as well.
- Empty asset link
- Empty favicon asset link.