coauthor icon indicating copy to clipboard operation
coauthor copied to clipboard

Update File needs to reload image

Open edemaine opened this issue 7 years ago • 8 comments

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 avatar Feb 24 '17 23:02 edemaine

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...

edemaine avatar Feb 27 '17 21:02 edemaine

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

diomidov avatar Jun 08 '19 19:06 diomidov

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?

edemaine avatar Jul 24 '19 20:07 edemaine

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.

jbosboom avatar Mar 16 '20 18:03 jbosboom

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.

edemaine avatar Mar 18 '20 20:03 edemaine

Still happens in Chromium :(

diomidov avatar Mar 19 '20 14:03 diomidov

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

edemaine avatar Nov 10 '21 23:11 edemaine

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

edemaine avatar Mar 05 '22 17:03 edemaine