Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/flask_caching/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from flask import current_app
from flask import Flask
from flask import g
from flask import request
from flask import Response
from flask import url_for
Expand Down Expand Up @@ -414,13 +415,15 @@ def decorated_function(*args, **kwargs):
if found and self.app.debug:
logger.info(f"Cache used for key: {cache_key}")
if response_hit_indication:
g.flask_caching_hit_cache = found

def apply_caching(response):
if found:
response.headers["hit_cache"] = found
if g.get("flask_caching_hit_cache"):
response.headers["hit_cache"] = g.flask_caching_hit_cache
return response

self.app.after_request_funcs[None].append(apply_caching)
if "apply_caching" not in self.app.after_request_funcs[None]:
self.app.after_request_funcs[None].append(apply_caching)

if not found:
rv = self._call_fn(f, *args, **kwargs)
Expand Down
Loading