add header showing brotli cache status
This commit is contained in:
parent
cdff524e3d
commit
639d209a95
|
@ -26,7 +26,9 @@ class BrotliCache(object):
|
|||
cache_key = 'brotlicache:{}'.format(digest)
|
||||
|
||||
encbody = self.redis.get(cache_key)
|
||||
response.headers.set('x-brotli-cache', 'HIT')
|
||||
if not encbody:
|
||||
response.headers.set('x-brotli-cache', 'MISS')
|
||||
lock_key = 'brotlicache:lock:{}'.format(digest)
|
||||
if self.redis.set(lock_key, 1, nx=True, ex=10):
|
||||
mode = brotli_.MODE_TEXT if response.content_type.startswith('text/') else brotli_.MODE_GENERIC
|
||||
|
|
Loading…
Reference in New Issue