Unify caching approach; use python-magic to compute content-type.