As reported earlier I had been given an Arduino Uno. I subsequently received my Ethernet Shield to hook the board up to the network. I’m clearly heading towards the Internet of things… Although I am still not 100% certain about what I’m going to do with the board (or how many additional ones I am going to have to buy) one things is pretty clear: It will have to be controllable and/or configurable over a web interface.
I found the Webserver example that ships with the Arduino IDE to be rather dull and unflexible. It wasn’t long before I stumbled upon Webduino, a very flexible generic Web Server library originally written by Ben Combee. The Webduino project homepage on Google Project Hosting points to this GitHub page. I downloaded the version adapted to Arduino 1.0 and started hacking away. Let me say this now: Webduino does meet my expectations.
However after a short while I ran into problems. None of them were to blame on the library, but rather on myself, but that’s actually not the point of this post… When I ran Wireshark to look at the data going over the network I noticed that for every page loaded Firefox also tries to download favicon.ico from the web server. Since Webduino sends a 400 error back on any requests for resources that have not been defined Firefox just keeps retrying forever.
At around the same time I discovered that, to avoid excess traffic from robots, there is a default robots.txt built into Webduino. So I decided to add a default favicon.ico, based on the icon used in the “Web_Image” example that ships with Webduino. Now when the first page is requested, Firefox loads the icon file, which actually eats more resources than one 400 error, but it pays off down the road when Firefox caches the icon and does not request it again, saving the Arduino from having to generate many 400 errors…
And since I see projects hosted on GitHub as an open invitation to fork I ended up with my own Webduino project on GitHub. Feel free to look at the code, to fork, clone, whatever (MIT license), and to let me know what you think! (Oh, and I gave the readme some TLC and also added a keywords.txt file for syntax highlighting.)
Update: I started to write a “beautiful” API documentation
Tags: Arduino, favicon.ico, git, Webduino
Cool, thanks for posting this.
It’s too bad you can’t just send a 410 GONE answer and expect a browser to properly remember it really doesn’t exist. But googling suggests browsers including firefox keep requesting favicon.ico even if it is told it is GONE.
That said, if you want to cut down on data a bit, an empty 200 OK for favicon.ico is handled acceptably by browsers (they just show no icon), and stops subsequent requests.
But as long as you’re sending an answer anyway, why not have a nice icon?
Comments feed for this article
Trackback link: https://ten-fingers-and-a-brain.com/2011/12/on-webduino-and-on-favicon-ico/trackback/