Move cache writing out of the transport.

This is necessary to unblock network interceptors, where the interceptor
may elect to rewrite the response body. If we've already cached the
original response body, we're too late.
Merge pull request #1218 from square/jwilson_1221_move_caching

Move cache writing out of the transport.