Files: preview URLs keep stale thumbnails for up to a day after changes

Open Beginner friendly
#67,592 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, php
Domain
frontend

Research direction

Start with apps/files/src/composables/usePreviewImage.ts at the linked lines, then check how Core/Controller/PreviewController.php sets preview cache headers. Trace how the ETag becomes the preview URL cache buster and run the relevant preview tests. Done when the URL changes for closely spaced ETag updates so the browser fetches the refreshed thumbnail.

Written by the indexing model from the issue text.

Description

1. to develop bug feature: files feature: previews and thumbnails
Bug description

The preview URL uses only the first 6 characters of the ETag (or of the mtime as fallback) as cache buster:

https://github.com/nextcloud/server/blob/3a68340a6c806a18cdd0d9667a3b9ec5f096b135/apps/files/src/composables/usePreviewImage.ts#L74-L75

while previews are cached by the browser for 24 hours as immutable:

https://github.com/nextcloud/server/blob/3a68340a6c806a18cdd0d9667a3b9ec5f096b135/core/Controller/PreviewController.php#L172

ETags generated with uniqid() (e.g. on object storage) only change their first 6 hex characters every 256 seconds, and the first 6 digits of a millisecond timestamp only every ~2.8 hours. So an image edited twice within a few minutes keeps showing the old thumbnail for up to a day. (The mtime fallback currently also throws, see #66919.)

Steps to reproduce

Found by code reading.

  1. With object storage as primary storage, upload an image and look at its thumbnail.
  2. Replace the image within a few minutes.
  3. The old thumbnail is still shown.
Expected behavior

The full ETag (or a hash of it) is used as cache buster.

Nextcloud version

master

Dominant language
PHP
Stars
37.7k
Forks
5.4k
Avg merge
1d 23h
Merged PRs (30d)
585

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nextcloud/server

All issues in nextcloud/server

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.