liveblog
liveblog copied to clipboard
Liveblog updates evading caches
The timestamps used by Liveblog result in many unique requests that are often uncacheable. We need to instead limit requests to time buckets of (for exampe) 10 seconds so that caches can more often serve up cached responses.
Here's a draft patch to expand on (props @darthhexx ):
diff --git a/src/react/services/api.js b/src/react/services/api.js
index d0f307d..2d7c43a 100644
--- a/src/react/services/api.js
+++ b/src/react/services/api.js
@@ -21,8 +21,8 @@ export function getEntries(page, config, newestEntry) {
}
export function polling(newestEntryTimestamp, config) {
- const timestamp = getCurrentTimestamp() + config.timeDifference;
-
+ let timestamp = getCurrentTimestamp() + config.timeDifference;
+ timestamp = timestamp + ( config.timeDifference - ( timestamp % config.timeDifference ) );
const settings = {
url: `${config.endpoint_url}entries/${(newestEntryTimestamp + 1) || 0}/${timestamp}/`,
method: 'GET',
See also @mjangda's patch at https://github.com/Automattic/liveblog/pull/496
Resolved by #496
I don't think this is quite fixed yet and needs more research + testing.
Cool, chatting with Nick on Monday and I have some ideas for tests that we can talk through then.