graceguo-supercat commented on a change in pull request #10963:
URL: 
https://github.com/apache/incubator-superset/pull/10963#discussion_r496464875



##########
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:
       at first i thought is_stale is a good idea. but when start refactor it, 
i found last_modified time is needed by decorator function(to set header). So 
is_stale (only boolean value) is not enough. 
   So instead of using is_stale return true or false, I prefer to keep 
get_last_modified, and use last_modified time to invalid cache.




----------------------------------------------------------------
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]

Reply via email to