Caching timeline, toots and media #14
Labels
No labels
bug
duplicate
feature
accepted
feature
proposal
help wanted
infrastructure
invalid
performance
question
user-agent/chromium
user-agent/webkit
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Rubicon/tutu#14
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is a discussion about caching toots and media. It’s needed feature because caching significantly reduces the "empty" time as the app started.
What’s more, We already have a very simple toot cache for hero animation. The new cache system can ease the burden to set the cache.
I think we may need separated:
The toot and media cache can be done with the Web Cache API, as they can be seen as atomic data. The timeline cache is composed data so we may need indexed db to implement it correctly.
Additionally, the timeline cache may need to able to have hole - if we don’t actually fetch the whole missing part of the timeline.
Compatibility:
a RPC server is added into the service worker - we can use it to communicate with the service worker.
CachedFetch
uses the Web Cache API, is landed as an experiment:97bd6da9ac
fetchStatus
uses it:export const fetchStatus = /* @__PURE__ */ new CachedFetch(
cacheBucket,
(session: RemoteServer, id: string) => {
const headers = new Headers({
Accept: "application/json",
});
if (isAccountKey(session)) {
headers.set("Authorization", `Bearer ${session.accessToken}`);
}
return {
url: new URL(`./api/v1/statuses/${id}`, session.site).toString(),
headers,
};
},
async (response) => {
return toSmallCamelCase(
await response.json(),
) as unknown as mastodon.v1.Status;
},
);
We will see if this way works out.
Added to v1.1.0, because some works have to do in this version:
fetchStatus
: check if the result is failed