Well, this is a bit of an issue with overlapping cache features, and that's why it's difficult to diagnose properly. I did some further tests, and your full size images are definitely caching in browser.
In the below screenshot, the image on the left was requested about the same time as the image on the right. The image on the left is clearly being served as cache. The image on the right only gets updated because I added some ?asdff
in the url, to force fresh request.
So just to conclude, these images are clearly getting cached. This is actually NORMAL behavior for images, although your case I see you are not adding cache-headers to images from the server. However, it's clearly another mechanism that is caching images either in browser or server, unrelated to Files gallery. What you are actually trying to resolve, is "how to make sure image files NEVER get cached". Your server is outputting three responses, one of which is likely related to the caching of images:
etag: "190d0-5ed8dadb07126"
via: 1.1 webcache1 (Varnish/trunk)
x-varnish: 454365430 157912629
If you want to avoid caching entirely, this needs to be resolved on your side. I can't say exactly what server settings you have, but the ones noted above are definitely involved.
tele_tubs When refreshing the browser nothing happens.
When refreshing an already-open "private" browser window, it will continue the session with cache. That's why you have the same cache issue in private window, until you open and close the window itself.
tele_tubs But then I don’t understand the next one. The pop-up full screen picture are not updated. It’s the same as the one I opened in the last incognito window. In normal mode the pop-up pic was always updated in chrome.
After my tests above, it's clear that your full size images are also caching. This is not caused by Files gallery (you can test by opening the image url directly in browser, as in my screenshots above).
tele_tubs But a new problem arose. The pop-up full screen picture will not update in chrome like it did in the start. After 30 minutes it updated one time.
Why this was working for you earlier, I don't know, but images are definitely caching somewhere. This is not caused by Files gallery or from the code you edited.
tele_tubs Next I added the return; where you told me to. I deleted cache in Chrome and now the preview images are updating when I refresh the browser every time.
This would basically prevent preview images from ever caching, because unlike full size images, Files gallery is in control of this request.
tele_tubs But in Safari it works fine now. Updating both preview image and fullscreen pictures. On my phone (Samsung with chrome) it also works fine now after adding the return. I don’t understand why Chrome stoped updating the full screen picture when it started to update the preview picture.
This gave some more clues. I tried to load the same image as from my screenshots into Safari, and it shows a CACHED version (from Chrome), even if the image was never loaded in that browser before.
The date is from 20 minutes ago, same as the request from Chrome.
100% certain, this is a server cache mechanism, probably related to via: 1.1 webcache1 (Varnish/trunk);x-varnish: 454365430 157912629
. Image response is cached on server (not in browser). Surely you are aware of these features on your server.
In my opinion, if you are setting up something like this, where you want to avoid anything from getting cached, surely you should plan appropriately and make sure your server is not caching anything. It's normal to cache images (static assets), and if you want to always prevent cache, you need to take correct measures up front to prevent this behavior.
Really, you shouldn't have to edit the code either, but this seems like workaround to block preview images from being affected by cache.