Skip to content

Conversation

st3iny
Copy link
Member

@st3iny st3iny commented Jun 18, 2025

Fix #11282

Each mailbox gets assigned with an etag which is generated from its id and all three sync tokens. This etag will be included in pre-fetch requests and the server will enable caching for the response.

If a mailbox is changed in the meantime, the etag will be different, resulting in a different URL which will cause the client to refetch the cached first page.

Etags are injected via initial state.

The cache duration of a week (immutable) is up for discussion. Please keep in mind that the newest state will always be fetched once a user opens a mailbox. The pre-fetch mechanism is more about preventing a loading skeleton when first opening a mailbox.

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@ChristophWurst
Copy link
Member

ChristophWurst commented Jun 25, 2025

If I read the Firefox network logs correctly the requests are not cached. I have turned on HTTP caching. Other requests, mostly images, are cached.

cache-control: private, max-age=604800, immutable

^ header is sent, but doesn't have the expected effect

@ChristophWurst
Copy link
Member

It works with Chromium. It says (disk cache).

@ChristophWurst
Copy link
Member

Spent more time than I should and still can't figure out why Firefox is not caching XHRs despite the cache headers

Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works in Chromium, Firefox situation unclear, could be my setup

@kesselb kesselb force-pushed the perf/cache-prefetched-mailboxes branch from b5c47c0 to 1af5574 Compare July 25, 2025 11:47
@kesselb
Copy link
Contributor

kesselb commented Jul 25, 2025

Nice, Thank you!

I expected something different when reading "ETag". It looks more like a cache buster, and the server will not respond with 204 status.

@st3iny st3iny force-pushed the perf/cache-prefetched-mailboxes branch from 1af5574 to c03980e Compare July 27, 2025 16:02
@st3iny
Copy link
Member Author

st3iny commented Jul 27, 2025

I renamed the parameter from etag to v to be more consistent with the rest of Nextcloud. I effectively implemented a cache buster rather than actually providing ETag functionality.

(The member of the serialized mailbox is called cacheBuster.)

Thanks @kesselb for the suggestion.

@st3iny st3iny enabled auto-merge July 27, 2025 16:04
@st3iny st3iny force-pushed the perf/cache-prefetched-mailboxes branch from c03980e to 0d02b07 Compare July 27, 2025 16:45
@st3iny
Copy link
Member Author

st3iny commented Jul 27, 2025

I included some unit tests ...

@st3iny st3iny force-pushed the perf/cache-prefetched-mailboxes branch from 0d02b07 to 6cc6cca Compare July 27, 2025 17:06
@st3iny st3iny force-pushed the perf/cache-prefetched-mailboxes branch from 6cc6cca to 0c4ac27 Compare July 27, 2025 17:07
@st3iny
Copy link
Member Author

st3iny commented Jul 27, 2025

/backport to stable5.1

@st3iny st3iny merged commit e903e79 into main Jul 27, 2025
44 checks passed
@st3iny st3iny deleted the perf/cache-prefetched-mailboxes branch July 27, 2025 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache first mailbox page on a HTTP level
3 participants