aboutsummaryrefslogtreecommitdiff
path: root/middleware
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-06-06 21:21:15 -0400
committerBobby <[email protected]>2023-06-06 21:21:15 -0400
commit5761ebb8969605aa76b47d2bad887bcb99e16858 (patch)
tree7f85d2a58b172595ee706abcf82cdec5c98452b4 /middleware
parenteae29d62051072ff1f0b4899260db1e684dcb42e (diff)
downloadthatcomputerscientist-5761ebb8969605aa76b47d2bad887bcb99e16858.tar.xz
thatcomputerscientist-5761ebb8969605aa76b47d2bad887bcb99e16858.zip
Do Not cache Blog admin paths
Diffstat (limited to 'middleware')
-rw-r--r--middleware/contentCachingMiddleware.py6
-rw-r--r--middleware/translationMiddleware.py4
2 files changed, 5 insertions, 5 deletions
diff --git a/middleware/contentCachingMiddleware.py b/middleware/contentCachingMiddleware.py
index 24118b78..a5820cd8 100644
--- a/middleware/contentCachingMiddleware.py
+++ b/middleware/contentCachingMiddleware.py
@@ -13,13 +13,13 @@ class ContentCachingMiddleware(object):
def __call__(self, request):
lang_cookie = request.COOKIES.get('lang', '')
+ path = request.get_full_path()
- # Don't cache POST requests
- if request.method == 'POST' or lang_cookie == 'ja':
+ # Don't cache POST requests or path contains 'blog-admin'
+ if request.method == 'POST' or lang_cookie == 'ja' or 'blog-admin' in path:
return self.get_response(request)
# Try to get cached response
- path = request.get_full_path()
cache_key = f'path_cache_{lang_cookie}:{path}'
cached_response = r.get(cache_key)
diff --git a/middleware/translationMiddleware.py b/middleware/translationMiddleware.py
index cfebbbdb..e7a1c1e2 100644
--- a/middleware/translationMiddleware.py
+++ b/middleware/translationMiddleware.py
@@ -21,8 +21,9 @@ class TranslationMiddleware:
# translate only if lang cookie is set to ja
response = self.get_response(request)
lang_cookie = request.COOKIES.get('lang', '')
+ path = request.get_full_path()
- if lang_cookie != 'ja':
+ if lang_cookie != 'ja' or 'blog-admin' in path:
return response
content_type = response.get('Content-Type', '').lower()
@@ -30,7 +31,6 @@ class TranslationMiddleware:
return response
# Try to get cached response
- path = request.get_full_path()
cache_key = cache_key = f'path_cache_{lang_cookie}:{path}'
cache_response = r.get(cache_key)