1.1 --- a/EventAggregatorSupport.py Mon Jul 25 00:07:03 2011 +0200
1.2 +++ b/EventAggregatorSupport.py Sat Aug 06 21:22:13 2011 +0200
1.3 @@ -1219,13 +1219,17 @@
1.4 cache_key = cache.key(request, content=url)
1.5 cache_entry = caching.CacheEntry(request, "EventAggregator", cache_key, scope='wiki')
1.6
1.7 - # If no entry exists, create one with the response from the URL.
1.8 - # NOTE: This could either be invalidated after a period of time,
1.9 - # NOTE: and/or the URL could be checked and the 'If-Modified-Since'
1.10 - # NOTE: header (see MoinMoin.action.pollsistersites) could be
1.11 - # NOTE: checked.
1.12 -
1.13 - if not cache_entry.exists():
1.14 + # If no entry exists, or if the entry is older than a certain age
1.15 + # (5 minutes by default), create one with the response from the URL.
1.16 +
1.17 + now = time.time()
1.18 + mtime = cache_entry.mtime()
1.19 + max_cache_age = int(getattr(request.cfg, "event_aggregator_max_cache_age", "300"))
1.20 +
1.21 + # NOTE: The URL could be checked and the 'If-Modified-Since' header
1.22 + # NOTE: (see MoinMoin.action.pollsistersites) could be checked.
1.23 +
1.24 + if not cache_entry.exists() or now - mtime >= max_cache_age:
1.25
1.26 # Access the remote data source.
1.27