Skip to content
Snippets Groups Projects
Commit e428d806 authored by Eric Frias's avatar Eric Frias
Browse files

Avoid parsing the response body when we've already decided not to

cache the result
parent 5fed86a4
No related branches found
No related tags found
1 merge request!10Avoid parsing the response body when we've already decided not to
......@@ -67,6 +67,8 @@ async def cache_response(request: HTTPRequest, response: HTTPResponse) -> None:
return
if 'x-jussi-error-id' in response.headers:
return
if request.jsonrpc.upstream.ttl == -1: #don't waste time parsing response if not cacheable
return
jsonrpc_response = loads(response.body)
if not jsonrpc_response:
return
......
......@@ -19,8 +19,8 @@ async def update_last_irreversible_block_num(request: HTTPRequest, response: HTT
return
request.timings.append((perf_counter(), 'update_last_irreversible_block_num.enter'))
try:
jsonrpc_response = ujson.loads(response.body)
if is_get_dynamic_global_properties_request(request.jsonrpc):
jsonrpc_response = ujson.loads(response.body)
last_irreversible_block_num = jsonrpc_response['result']['last_irreversible_block_num']
cache_group = request.app.config.cache_group
request.app.config.last_irreversible_block_num = last_irreversible_block_num
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment