I love decorators. Python is a pretty concise language but all too often you can end up with cluttered code thats full of monitoring and debugging logic. Let’s take some pretty typical code and see if we can improve it with some decorators. This post uses timing as a contrived example, in the real world you’ll probably just want to using a pre-existing timing decorator and be done with it. Realistically you’ll find decorators useful for things like authentication, metrics, logging, tracing and really anything where you want to do something before or after a callable.

Varnish Debugging

I love Varnish. As far as the world of HTTP goes, in environments where you can cache it’s one of the easiest quick wins there is. However this does somewhat come at a price to debugging. Often you’ll sit back and your black box of magic doesn’t quite produce the result you were expect from it. Normally I end up adding a sleuth of headers cache status headers to help identify where things are going wrong.