Skip to content

Commit 601a579

Browse files
committed
get found from request context
1 parent 494d498 commit 601a579

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/flask_caching/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
from flask import current_app
2828
from flask import Flask
29+
from flask import g
2930
from flask import request
3031
from flask import Response
3132
from flask import url_for
@@ -414,10 +415,11 @@ def decorated_function(*args, **kwargs):
414415
if found and self.app.debug:
415416
logger.info(f"Cache used for key: {cache_key}")
416417
if response_hit_indication:
418+
g.flask_caching_hit_cache = found
417419

418420
def apply_caching(response):
419-
if found:
420-
response.headers["hit_cache"] = found
421+
if g.flask_caching_hit_cache:
422+
response.headers["hit_cache"] = g.flask_caching_hit_cache
421423
return response
422424

423425
self.app.after_request_funcs[None].append(apply_caching)

0 commit comments

Comments
 (0)