graceguo-supercat commented on a change in pull request #10963:
URL:
https://github.com/apache/incubator-superset/pull/10963#discussion_r496295822
##########
File path: superset/utils/decorators.py
##########
@@ -89,13 +94,26 @@ def wrapper(*args: Any, **kwargs: Any) -> ETagResponseMixin:
raise
logger.exception("Exception possibly due to cache
backend.")
+ # if cache is stale?
+ if get_latest_changed_on:
+ content_changed_time = get_latest_changed_on(*args, **kwargs)
+ if (
+ response
+ and response.last_modified
+ and response.last_modified.timestamp()
+ < content_changed_time.timestamp()
+ ):
+ response = None
+ else:
+ content_changed_time = datetime.utcnow()
Review comment:
We use this `content_changed_time` as cache's last_modified time.
for dashboard `content_changed_time` is dashboard entity's latest updated
time (like metadata, chart metadata changed time etc). this data is from a
callback function.
for explore_json, the cache is query results and there is no entity's latest
modified time to use. so we use request time (now) as cache's last_modified
time.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]