@@ -318,9 +318,14 @@ def run_check():
318318 else :
319319 details = self_comp_res
320320
321- # Run the check if details is None or forced to populate the cache.
321+ # Run the check if details is None or forced to populate the cache or
322+ # the cache is outdated.
322323 if self_comp_res is None or force_run_check is not None :
323324 threading .Thread (target = run_check ).start ()
325+ elif self_comp_res is not None :
326+ timestamp = self_comp_res .get ('timestamp' )
327+ if not badge_utils ._is_github_cache_valid (timestamp ):
328+ threading .Thread (target = run_check ).start ()
324329
325330 badge = badge_utils ._get_badge (details , badge_name )
326331 response = flask .make_response (badge )
@@ -418,9 +423,14 @@ def run_check():
418423 else :
419424 details = dependency_res
420425
421- # Run the check if dependency_res is None or forced to populate the cache.
426+ # Run the check if dependency_res is None or forced to populate the cache
427+ # or the cache is outdated.
422428 if dependency_res is None or force_run_check is not None :
423429 threading .Thread (target = run_check ).start ()
430+ elif dependency_res is not None :
431+ timestamp = dependency_res .get ('timestamp' )
432+ if not badge_utils ._is_github_cache_valid (timestamp ):
433+ threading .Thread (target = run_check ).start ()
424434
425435 badge = badge_utils ._get_badge (details , badge_name )
426436 response = flask .make_response (badge )
@@ -533,9 +543,14 @@ def run_check():
533543 else :
534544 details = google_comp_res
535545
536- # Run the check if google_comp_res is None or forced to populate the cache.
546+ # Run the check if google_comp_res is None or forced to populate the cache
547+ # or the cache is outdated.
537548 if google_comp_res is None or force_run_check is not None :
538549 threading .Thread (target = run_check ).start ()
550+ elif google_comp_res is not None :
551+ timestamp = google_comp_res .get ('timestamp' )
552+ if not badge_utils ._is_github_cache_valid (timestamp ):
553+ threading .Thread (target = run_check ).start ()
539554
540555 badge = badge_utils ._get_badge (details , badge_name )
541556 response = flask .make_response (badge )
0 commit comments