Our current model for notes polling is to always add notes. I think it is possible to invalidate the cache when any note is edited or deleted, but we would need to fetch all notes instead. This would also only be on issues initially.
It looks like NotesFinder already returns edited notes, because it queries by updated_at. We also expire ETag cache when a note is edited (or deleted). After reading notes.js I believe that it simply ignores these edited notes. Modifying the JavaScript should be all that we need.
Deleted notes
This is harder, because we don't have these deleted notes in the database, so we can't query for them. I can think of two options:
Implement "soft deleting" for notes - keep them in the database so we can return "recently deleted" ones.
Remove our mechanism for incremental updates and just return all notes
I believe that option 2 is better in general (at least from the backend perspective). Returning all the data is easier to reason about than incremental updates and we will remove a mechanism that is only used for notes (different than other places where we do polling).
We share the code between issue notes polling, merge request polling and so on. We would have to support two parallel flows both in notes.js and NotesFinder if we want to do this only for issues.
On a cache hit, the backend returns 304, but the response is intercepted by the browser and the previous response is served from cache, so it's transparent from the point of view of the JavaScript code. This requires some smart diffing mechanism if we want to avoid re-rendering all the notes every few seconds.
To sum up, I'm in favour of doing the easy thing - edited notes and postponing deleted notes.
@smcgivern I couldn't believe that edits are deletions are so rare and I thought that our monitoring is broken. But it's not, I tested it out, It tracked my requests, so they are really that uncommon.