Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

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.

Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
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

);

$response = new JSONResponse($messages);
if ($etag) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: use explicit null comparison to avoid funny PHP comparisons

@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

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
2 participants