Skip to content

fix(imap): cache message body#12082

Merged
kesselb merged 1 commit intomainfrom
bug/noid/cache-message-body
Nov 26, 2025
Merged

fix(imap): cache message body#12082
kesselb merged 1 commit intomainfrom
bug/noid/cache-message-body

Conversation

@kesselb
Copy link
Copy Markdown
Contributor

@kesselb kesselb commented Nov 25, 2025

Should help with #10384

For HTML messages we already know that after the "body" request there is also an "html" request which also needs the body part, so keeping them in cache makes it a bit faster.

I went with distributed because even in these cases I would expect a small improvement. We skip the usual IMAP handshake and just fetch what we need.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
}

private function getCacheForAccount(int $accountId): ICache {
return $this->cacheFactory->createDistributed('mail_account_' . $accountId);
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.

Missing check for cache availability?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The check for cache availability is not missing. createDistributed might return a null cache instance; that's fine and we just go ahead and fetch the part.

@ChristophWurst
Copy link
Copy Markdown
Member

I went with distributed because even in these cases I would expect a small improvement.

What is the improvement?

@kesselb
Copy link
Copy Markdown
Contributor Author

kesselb commented Nov 26, 2025

What is the improvement?

For "html" messages, we know that there will be another http request for the iframe. As we already have the HTML body, it's a shortcut to store it in the cache, saving us one imap request. Fetching the data from the distributed cache should be, in most cases, faster than talking to the imap server and parsing that response.

@ChristophWurst
Copy link
Copy Markdown
Member

Okay, got it. Cache is definitely faster than IMAP 👍 As usual I would just consider the local cache due to lower latency.

@kesselb kesselb merged commit 9c1f290 into main Nov 26, 2025
44 checks passed
@kesselb kesselb deleted the bug/noid/cache-message-body branch November 26, 2025 12:13
@kesselb
Copy link
Copy Markdown
Contributor Author

kesselb commented Nov 26, 2025

/backport to stable5.6

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.

2 participants