Skip to content

Commit

Permalink
update last_checked when validating etag
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed Apr 24, 2024
1 parent fd3b8ee commit 6c26f87
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ async def proxy():

headers = {'Authorization': f'token {token}'}

logger.info(cached_resp["last_checked"])
logger.info(last_checked)
logger.info(current_time)

if cached_resp and "etag" in cached_resp:
if "last_checked" in cached_resp and current_time - last_checked < 60:
logger.info(f"Using newly cached data for URL: {url_to_fetch}")
Expand All @@ -148,8 +144,8 @@ async def proxy():
logger.info(log_msg)

if response.status_code == 304:
logger.info(
f"Using cached data for URL: {url_to_fetch}")
logger.info(f"Using cached data for URL: {url_to_fetch}")
await set_to_cache(url_to_fetch, cached_resp["data"], cached_resp["etag"])
return jsonify(json.loads(cached_resp["data"]))
elif response.status_code == 200:
await set_to_cache(url_to_fetch, response.json(), response.headers.get('ETag', ''))
Expand Down

0 comments on commit 6c26f87

Please sign in to comment.