def METHOD_NAME(response):
    response_time = (time.time() - current_app.request_start_time) * 1000
    accept_encoding = request.headers.get("Accept-Encoding", "")
    _log_request(response_time)
    if "gzip" not in accept_encoding.lower():
        return response
    response.direct_passthrough = False
    if (
        response.status_code < 200
        or response.status_code >= 300
        or "Content-Encoding" in response.headers
    ):
        return response
    response.data = compression.gzip_compress(response.data)
    response.headers["Content-Encoding"] = "gzip"
    response.headers["Vary"] = "Accept-Encoding"
    response.headers["Content-Length"] = len(response.data)
    return response