Caching timeline, toots and media #14

Open
opened 2024-09-25 07:00:44 +00:00 by Rubicon · 5 comments
Owner

This is a discussion about caching toots and media. It’s needed feature because caching significantly reduces the "empty" time as the app started.

This is a discussion about caching toots and media. It’s needed feature because caching significantly reduces the "empty" time as the app started.
Rubicon added the
feature
proposal
label 2024-09-25 07:00:44 +00:00
Author
Owner

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.

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.
Author
Owner

I think we may need separated:

  • timeline cache
  • toot cache and media cache

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:

  • IndexedDB 2.0: all targets support
  • Web Cache API: all targets support
I think we may need separated: - timeline cache - toot cache and media cache 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: - IndexedDB 2.0: all targets support - Web Cache API: all targets support
Author
Owner

a RPC server is added into the service worker - we can use it to communicate with the service worker.

a RPC server is added into the service worker - we can use it to communicate with the service worker.
Rubicon added this to the (deleted) project 2024-10-18 14:52:18 +00:00
Rubicon removed this from the (deleted) project 2024-10-20 12:41:22 +00:00
Author
Owner

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.

`CachedFetch` uses the Web Cache API, is landed as an experiment: https://code.lightstands.xyz/Rubicon/tutu/commit/97bd6da9ac3e4aec29d73d4bf5cae1dc6d513dbf `fetchStatus` uses it: https://code.lightstands.xyz/Rubicon/tutu/src/commit/5742932c8609dee1de254a5f0bee5f957592408c/src/masto/statuses.ts#L11-L30 We will see if this way works out.
Rubicon added this to the v1.1.0 project 2024-12-26 14:12:49 +00:00
Author
Owner

Added to v1.1.0, because some works have to do in this version:

  • Settings: add an option to delete the cache
  • fetchStatus: check if the result is failed
Added to v1.1.0, because some works have to do in this version: - [x] Settings: add an option to delete the cache - [x] `fetchStatus`: check if the result is failed
Rubicon added the
infrastructure
label 2024-12-26 14:24:28 +00:00
Rubicon modified the project from v1.1.0 to v2.0.0 2025-01-01 13:24:29 +00:00
Rubicon self-assigned this 2025-01-01 14:21:16 +00:00
Sign in to join this conversation.
No description provided.