Skip to content

perf: cache pre-fetched mailboxes on the HTTP level#11293

Merged
st3iny merged 1 commit into
mainfrom
perf/cache-prefetched-mailboxes
Jul 27, 2025
Merged

perf: cache pre-fetched mailboxes on the HTTP level#11293
st3iny merged 1 commit into
mainfrom
perf/cache-prefetched-mailboxes

Conversation

@st3iny

@st3iny st3iny commented Jun 18, 2025

Copy link
Copy Markdown
Member

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.

@ChristophWurst ChristophWurst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good

Comment thread lib/Controller/MessagesController.php Outdated
@ChristophWurst

ChristophWurst commented Jun 25, 2025

Copy link
Copy Markdown
Member

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
Copy Markdown
Member

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

@ChristophWurst

Copy link
Copy Markdown
Member

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

@ChristophWurst ChristophWurst left a comment

Copy link
Copy Markdown
Member

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

kesselb commented Jul 25, 2025

Copy link
Copy Markdown
Contributor

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

st3iny commented Jul 27, 2025

Copy link
Copy Markdown
Member Author

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

st3iny commented Jul 27, 2025

Copy link
Copy Markdown
Member Author

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
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
@st3iny st3iny force-pushed the perf/cache-prefetched-mailboxes branch from 6cc6cca to 0c4ac27 Compare July 27, 2025 17:07
@st3iny

st3iny commented Jul 27, 2025

Copy link
Copy Markdown
Member Author

/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
@github-actions

Copy link
Copy Markdown

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

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