aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-06-06 17:52:07 -0400
committerBobby <[email protected]>2023-06-06 17:52:07 -0400
commitd0384f82bd2449e6f6b1abe4fb4491e20664a736 (patch)
tree364f083ef3ca674f79c5a66a266f55e05873815e
parentf09e63bcaa209a102a722bfc2f375c72dc0fd726 (diff)
downloadthatcomputerscientist-d0384f82bd2449e6f6b1abe4fb4491e20664a736.tar.xz
thatcomputerscientist-d0384f82bd2449e6f6b1abe4fb4491e20664a736.zip
Cache the Google Safe Browsing result for link safety
-rw-r--r--blog/context_processors.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/blog/context_processors.py b/blog/context_processors.py
index 92f3b71c..f43274d8 100644
--- a/blog/context_processors.py
+++ b/blog/context_processors.py
@@ -134,6 +134,8 @@ def check_link_safety(link):
if response.status_code == 200:
# Successful API call
matches = response.json().get('matches', [])
+ # Cache the result
+ cache.set(cache_key, len(matches) == 0, cache_timeout)
return len(matches) == 0
else:
# Handle API error