performance impact of large /etc/hosts files

Alex Zbyslaw xfb52 at
Wed Dec 12 06:52:34 PST 2007

Heiko Wundram (Beenic) wrote:

>Basically, why I personally rather like the squid (i.e., proxy-based) approach 
>to ad-blocking is the fact that if you try to do this at a lower level than 
>the HTTP-level, there's bound to be pages that display wrong/broken, simply 
>because not being able to fetch images (because they supposedly come 
>from "localhost") means that most browsers are not going to display the space 
>reserved to it and will mess up the page layout, even when specifying width= 
>_and_ height= in an img-tag (when only specifying one of the attributes or 
>none, the page layout will be broken anyway). Opera is my favourite candidate 
>for messing up page layouts in this case.
>On another note, Opera has an (IMHO) huge timeout for failed (i.e., refused, 
>not timed out) connections to the target host, and if many images refer to 
>localhost through some DNS or hosts magic, this is going to majorly slow down 
>page display/buildup on non-css based layouts, which sadly there still are 
>enough out there (and for some of which the ad-slots are an integral part of 
>the page layout, such as some german news sites).
I'm certainly convinced that this is a viable solution to the ad 
problem, but it still seems *to me* far more work than dumping a bunch 
of hostnames in /etc/hosts.  I have, myself, had little or no trouble 
with page layouts messing up, but I maybe haven't used the solution on a 
large enough scale to notice.  But if you really want to configure the 
heck out of ads then squid would seem to have much more flexibility, at 
the cost of greater maintenance.

As for the timeouts issue, you are assuming that the host names are 
redirected to an IP address where nothing is listening.  I redirect to a 
local IP alias and do have an apache server listening which serves up a 
default page with a blue background.  I want to *see* the ad being 
blocked as it gives me a sense of smug satisfaction :-)  I'm sure you 
could do something more sophisticated, but this has worked well enough 
for me with virtually no maintenance.  I certainly get no noticeable 
delays with opera when I use it.



PS The /etc/hosts solution must be described plenty of places that are 
google-able since I found it through none of the resources mentioned in 
this discussion.  I wish I could say I'd thought of it for myself, but 
like so many good ideas I just borrowed it shamelessly from somewhere else.

More information about the freebsd-questions mailing list