edemaine / coauthor

Coauthor supercollaboration/discussion forum
MIT License
252 stars 35 forks source link

Update File needs to reload image #163

Open edemaine opened 7 years ago

edemaine commented 7 years ago

Now that URLs to files are based on message ID without any version number (#77), updating the file requires a refresh of the same URL (otherwise, the old image still appears until refreshing the page).

Related: Refresh image with a new one at the same url. Yuck.

Should URLs have a version number in all cases? E.g. /file/messageID?v=5? Version could default to latest, and I guess ?v=5 could be stripped when dragging... For this to work, would probably need #34.

edemaine commented 7 years ago

In our testing, Chrome and Safari will refresh when the image has a Cache-Control: no-store header; see this Chromium report. Unfortunately, this is not true for Firefox, so not really an option...

Jeffrey suggested embedding using <object> tags, which seems to avoid the special "ignore higher-layer caching flag" behavior of the HTML standard. Unfortunately, <object>s (at least on Chrome, despite what the spec says) seem to represent images as embedded documents, which means they don't scale the image correctly. (Large images get clipped, with possible scrollbars.) So this isn't an option either.

We also discussed using this hack to display one image (internal URL) but cause right clicks to bind to the other image (desired public-facing URL). This trick requires knowing the width and height of the image, though, so it's difficult with current Coauthor infrastructure (which doesn't know this information at the database level).

I've therefore opted for Doin's solution 4 (reload via iframe). It actually seems to work...

diomidov commented 5 years ago

This bug is back in Chromium 74.0.3729.169 (it works fine in Firefox 67.0)

edemaine commented 5 years ago

A possible alternative would be to do an XHR, maybe with Cache-Control: no-cache; or if server says Cache-Control: must-revalidate or maybe Cache-Control: stale-while-revalidate (see MDN and guide), maybe everything will work just by removing from DOM and adding back?

jbosboom commented 4 years ago

In Firefox 72.0.2, when I replace a file, the file is briefly replaced with some text (that says "updating", I think), then the original image is shown again. Refreshing the page does not fix it.

As a workaround, the history view shows the most recent image.

edemaine commented 4 years ago

I set Cache-Control: stale-while-revalidate so this should now be fixed. At least, it fixed my local Firefox testing -- I had trouble reproducing the original problem on Chrome. Let me know if you run into this issue again.

diomidov commented 4 years ago

Still happens in Chromium :(

edemaine commented 3 years ago

Since July 2021, this should happen "a lot less", on Chrome and Firefox. But I still see it happen occasionally. ☹️

edemaine commented 2 years ago

I made some more tweaks to this. I'm hoping that it's actually fixed now. Let me know if you observe otherwise.