The problem is that if you serve favicon.ico by defining it as django url (like the code below):
(r'^favicon\.ico$',
'django.views.generic.simple.redirect_to',
{'url': settings.MEDIA_URL+'images/favicon.ico'}),
All your middleware get called twice: 1 time for the page you have requested + 1 time for the favicon (which is always called by the browser). The solution is simple: don't use django urls to serve your vaficon, instead put something like:
<link rel="icon" type="image/png" href="{% static 'core/img/favicon.ico' %}" />
in the <head>
of your base template!