Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Thumbnail doesn't update when source image is changed #44630

Closed
5 of 8 tasks
rightsaidfred99 opened this issue Apr 3, 2024 · 14 comments · Fixed by #45417
Closed
5 of 8 tasks

[Bug]: Thumbnail doesn't update when source image is changed #44630

rightsaidfred99 opened this issue Apr 3, 2024 · 14 comments · Fixed by #45417

Comments

@rightsaidfred99
Copy link

⚠️ This issue respects the following points: ⚠️

Bug description

If you upload an image to Nextcloud (via external storage), the thumbnail will load as normal.
However when you replace the source image, Nextcloud will sitll use the old thumbnail for the image.

This wasn't the case a few years ago

Steps to reproduce

  1. Upload an image to NC via SMB or external storage method
  2. Open NC on an iPad, goto the directory and the thumbnail will generate
  3. Upload a new image or tweaked image to NC via SMB or external method, as long as original image is replace
  4. Open NC again and the old image thumbnail will still be used even though NC will show the image is modified

Expected behavior

NC should always be showing the thumbnail that represents the source image

Installation method

Community Docker image

Nextcloud Server version

28

Operating system

Other

PHP engine version

PHP 8.3

Web server

None

Database engine version

MariaDB

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

Encryption is Disabled

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

No response

List of activated Apps

No response

Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

No response

@rightsaidfred99 rightsaidfred99 added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Apr 3, 2024
@invario
Copy link

invario commented Apr 8, 2024

Are you certain it's not your browser that simply cached the thumbnail? Force a refresh (e.g. in Chrome, press Ctrl-F5 to force a reload of images).

@rightsaidfred99
Copy link
Author

It happens on the macOS app, desktop (chrome or safari) which leads me to believe it might be a caching thing.

@ostasevych
Copy link

Are you certain it's not your browser that simply cached the thumbnail? Force a refresh (e.g. in Chrome, press Ctrl-F5 to force a reload of images).

Actually, I experience the same. And I need manually click Ctrl-F5 each time after modifying the file.

@f0k
Copy link

f0k commented May 17, 2024

NextCloud tells the browser that it can rely on the cached version for 24 hours, and only has to re-check with the server (with a conditional request) after that time has passed:

@rightsaidfred99
Copy link
Author

But if the source image changes, shouldn't there be a trigger where the thumbnail gets redone? I swear that used to happen years ago.

@f0k
Copy link

f0k commented May 18, 2024

But if the source image changes, shouldn't there be a trigger where the thumbnail gets redone?

The thumbnail probably gets redone, but your browser does not ask the server for it, only after 24 hours or when you press Ctrl+F5. The server sends a Cache-Control: max-age=86400, must-revalidate header, so the browser will not request the image from the server again for 24 hours (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching for all the details). Whether this is a too long timespan is discussable, of course. In a browser you can usually bypass the cache by using Ctrl+F5.

@szaimen
Copy link
Contributor

szaimen commented May 18, 2024

Cc @nextcloud/server-frontend

@rightsaidfred99
Copy link
Author

You can't Ctrl+F5 on an iPad or Android phone though?

@ostasevych
Copy link

But if the source image changes, shouldn't there be a trigger where the thumbnail gets redone?

The thumbnail probably gets redone, but your browser does not ask the server for it, only after 24 hours or when you press Ctrl+F5. The server sends a Cache-Control: max-age=86400, must-revalidate header, so the browser will not request the image from the server again for 24 hours (see https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching for all the details). Whether this is a too long timespan is discussable, of course. In a browser you can usually bypass the cache by using Ctrl+F5.

That is a bad behaviour. There are online graphic editors which easily update the picture on the fly. Why it is not possible to do that in this app?

@skjnldsv
Copy link
Member

skjnldsv commented May 21, 2024

We usually add an etag to the preview fetch. At least the web interface does.
So it does fetch the new preview when the file changes.

@rightsaidfred99 you mentionned the ipad, you mean with the NC iOS/macOS app?
Or are you referring to Nextcloud through a browser?

@rightsaidfred99
Copy link
Author

@skjnldsv yes, the iOS app specifically. But the same thing also happens on the web interface I guess.

@skjnldsv
Copy link
Member

Ah, it seems the webalso needs a fix, I thought we fixed it 🤔

@skjnldsv skjnldsv self-assigned this May 21, 2024
@skjnldsv skjnldsv added 1. to develop Accepted and waiting to be taken care of and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels May 21, 2024
@skjnldsv skjnldsv added 3. to review Waiting for reviews feature: files and removed 1. to develop Accepted and waiting to be taken care of labels May 21, 2024
@f0k
Copy link

f0k commented May 21, 2024

We usually add an etag to the preview fetch. At least the web interface does. So it does fetch the new preview when the file changes.

@skjnldsv: The etag will not help here: Because of the max-age=86400, the client will not ask the server about the preview image for 24 hours. Only when the cached version is older than 24 hours (i.e., it is stale), it will send a conditional request to the server with the cached modification time and etag and then either only get a 304 not modified header (when the file has not changed), or a 200 response with the new preview image. If this is unintended, then the cacheFor call cited above should get a much shorter max-age, or no max-age should be set at all.

@susnux
Copy link
Contributor

susnux commented May 21, 2024

no max-age should be set at all

This is very bad and can lead to very high load of your webserver if you load a directory with a lot of images and navigation fast (and you have a large user base).

Instead we can use some kind of tag on the url like preview.png?etag=xxxx so the is a cache buster if the file changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants