NodeJS Express wildcard route executed several times

Consider the following code snippet:

var count = 0;

function a(req, res, next){
   count++;
   console.log(count);
   next();
};

app.get('*', a);
app.get("/", routes.index);
app.get("/foo", routes.foo);

Function a() will be executed for every route defined, in this case 2, per http request. The count variable is just to illustrate. So if I had 100 routes defined, a() would be executed 100 times per request to the site. Is this the expected behavior, or am I doing something wrong? Thanks!

You should check out the network traffic or log the request in your a function. Most likely the second request you are seeing is for favicon.ico. Each route when only be called once per matching request.