Tag Tracking+ fetch optimization ideas #835
marcustyphoon
started this conversation in
Tech Office
Replies: 2 comments 9 replies
-
ah shit, I had a redpop branch ready to PR with that, and then I got drowned by like three simultaneous discussions and forgot |
Beta Was this translation helpful? Give feedback.
5 replies
-
is this not already true for tumblr itself hitting |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is this worthwhile? Ehhhhh. At the very least, low priority unless we start hitting the API hard enough to cause problems with the current code.
Right now, with Tag Tracking+ active...
a) navigating to another Tumblr page (including using the buttons that the script itself adds to the sidebar, unless we manage to steal a soft navigate hook) fires
number of tracked tags
apifetches even if the last navigation was very recent and the data is still freshb) having multiple tumblr tabs open fires
number of tabs
apifetches every 30 seconds instead of one every 30 secondsc) having a tumblr tab in the background that you never look at for a long period of time fires
minutes * 2
apifetches that you never really see the result ofTo optimize this, my proposal is to:
[unreadCountString, lastFetched]
values under a new storage key (separate keys avoid race condition); read this in place of the unreadCounts MaprefreshAll(isFirstRun)
function which:isFirstRun === false
and anylastFetched
is within the previous 30 seconds, return (fixes b)document.visibilityState === 'hidden'
, return (fixes c)lastFetched
is older thanisFirstRun ? 30s : numberOfTags * 30s
; if none, select the oldest tag*lastFetched
values to now and fetch them allunreadCounts
refreshAll()
on a 30s intervalThis should ensure that hard refreshing gives relatively recent data (30 seconds) without unnecessary API requests, no data is more outdated than
number of tracked tags * 30 seconds
, and having a page in the background for a long period causes no additional api fetches but instantly freshens up the data when you tab back to it. And in the "normal" case this should still result in the 30 second cascading refresh behavior.*actually, "select every tracked tag whose
lastFetched
is older thanisFirstRun ? 30s : numberOfTags * 60s
; if none, select the oldest tag if it's older thannumberOfTags * 30s
" mirrors the current behavior. Either way.Beta Was this translation helpful? Give feedback.
All reactions