Exclude auth endpoints from ETag cache
LocationBasedServices/smartguide/pipeline/head This commit looks good
LocationBasedServices/smartguide/pipeline/head This commit looks good
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
# middleware/etag_cache.py
|
||||
import hashlib, json, time
|
||||
import hashlib
|
||||
import json
|
||||
import time
|
||||
|
||||
from starlette.middleware.base import BaseHTTPMiddleware
|
||||
from starlette.requests import Request
|
||||
from starlette.responses import Response
|
||||
@@ -22,6 +25,12 @@ class ETagCacheMiddleware(BaseHTTPMiddleware):
|
||||
if request.method != "GET":
|
||||
return await call_next(request)
|
||||
|
||||
if request.url.path.startswith(("/api/auth", "/api/accounts")):
|
||||
return await call_next(request)
|
||||
|
||||
if request.headers.get("authorization"):
|
||||
return await call_next(request)
|
||||
|
||||
key = self._cache_key(request)
|
||||
entry = self.cache.get(key)
|
||||
client_etag = request.headers.get("if-none-match")
|
||||
|
||||
Reference in New Issue
Block a user