liveblog icon indicating copy to clipboard operation
liveblog copied to clipboard

Liveblog updates evading caches

Open philipjohn opened this issue 7 years ago • 4 comments

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',

philipjohn avatar Jun 13 '18 09:06 philipjohn

See also @mjangda's patch at https://github.com/Automattic/liveblog/pull/496

paulschreiber avatar Aug 15 '18 16:08 paulschreiber

Resolved by #496

philipjohn avatar Sep 28 '18 10:09 philipjohn

I don't think this is quite fixed yet and needs more research + testing.

mjangda avatar Sep 28 '18 15:09 mjangda

Cool, chatting with Nick on Monday and I have some ideas for tests that we can talk through then.

philipjohn avatar Sep 28 '18 15:09 philipjohn