mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
Investigation into #12876, a mysterious bug where users were seeing messages reappear as unread, determined that the root cause was missing headers to disable client-side caching for Zulip's REST API endpoints. This manifested, in particular, for `GET /messages`, which is essentially the only API GET endpoint used by the webapp at all. When using the `Ctrl+Shift+T` feature of browsers to restore a recently closed tab (and potentially other code paths), the browser would return from its disk cache a cached copy of the GET /messages results. Because we include message flags on messages fetched from the server, this in particular meant that those tabs would get a stale version of the unread flag for the batches of the most recent ~1200 messages that Zulip fetches upon opening a new browser tab. The issue took same care to reproduce as well, in large part because the arguments to those initial GET /messages requests will vary as one reads messages (because the `pointer` moves forward) and then enters the "All messages" view; the disk cache is only used for GET requests with the exact same URL parameters. We will probably still want to merge the events error-handling changes we had previously proposed for this, but the conclusion of this being a straightforward case of missing cache-control headers is much more satisfying than the "badly behaving Chrome" theory discussed in the issue thread. Fixes #12876.