diff options
author | Julien Cristau <jcristau@debian.org> | 2018-07-06 23:56:42 +0200 |
---|---|---|
committer | Julien Cristau <jcristau@debian.org> | 2018-07-06 23:56:42 +0200 |
commit | 9722d64fc465c549d47bb7b1d8ea02355fdb700d (patch) | |
tree | 42ac935100e0dfc71901764114b82ab3356da5f2 /bin/tracker_service.py | |
parent | 6be1cdba2f755ec59935d418b80c87bebdf5fba9 (diff) |
Fix check for whether /tracker/data/json needs to be recomputed
In commit 49e287d2574ed385e31ce3d36cb3cb19f4c7785f "tracker_service:
send a Last-Modified header for /tracker/data/json" I made the
json_timestamp update conditional on whether the data had changed. That
meant that after a few minutes, we would consider the data to be always
stale, and recompute it every single time, as long as it didn't change.
To fix this, use separate timestamps for "when did we check last"
(json_timestamp) and "when did it change last" (json_last_modified).
Diffstat (limited to 'bin/tracker_service.py')
-rwxr-xr-x | bin/tracker_service.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/tracker_service.py b/bin/tracker_service.py index 6dda2d48d0..38e01022ae 100755 --- a/bin/tracker_service.py +++ b/bin/tracker_service.py @@ -137,6 +137,7 @@ class TrackerService(webservice_base_class): self.db = security_db.DB(db_name) self.json_data = None # the JSON dump itself self.json_timestamp = None # timestamp of JSON generation + self.json_last_modified = None self.register('', self.page_home) self.register('*', self.page_object) self.register('redirect/*', self.page_redirect) @@ -1452,14 +1453,15 @@ Debian bug number.'''), # store the JSON dump in memory, and update the generation # timestamp before returning new_data = json.dumps(data, separators=(',', ':')) + self.json_timestamp = time.time() if new_data != self.json_data: self.json_data = new_data - self.json_timestamp = time.time() + self.json_last_modified = self.json_timestamp return self.json_data def page_json(self, path, params, url): result = BinaryResult(self._get_json(),'application/json') - result.headers['Last-Modified'] = email.utils.formatdate(self.json_timestamp, usegmt=True) + result.headers['Last-Modified'] = email.utils.formatdate(self.json_last_modified, usegmt=True) return result def page_debsecan(self, path, params, url): |