[Bug]: Very first download is always 50% slow speed, but following downloads of the same file are ok, cache logic issues?
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- Nextcloud Server is running on 64bit capable CPU, PHP and OS.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
Nextcloud seems to make some kind of unadvertised caching of files before serving them for the very first time, I'm experiencing this:
- The very first time that you download a big file, it always downloads at 50% of speed of your connection or disk max speed capability. Following downloads are just fine, x2 increase of download speed at full capacity.
- Downloads don't start immediately, there is a significant delay like 10 or more seconds before any byte is downloaded.
- There are some apache processes that continue reading the file from the disk even after the browser has completely downloaded the file, this happens for several seconds.
1 - Very first download of a file at 50MB/S:
I can see that clearly there are 3 apache processes reading from the device the very first time:

Real client speed:

2 - Following downloads of the same file goes to full speed 107 MB/S:
Here i can only see 2 apache2 processes insetead of 3 (as very first download):

Real client speed

Steps to reproduce
I installed this with the official helm chart and official default apache config that the helm chart performs.
- Download a file and analyze apache2 processes of nextcloud with a tool like iotop or similar. You will see 3 apache2 processes for just a unique download reading from disk unnecessariliy.
- After download ends in the client, apache2 processes keeps reading disk anyway. There seems to be some caching logic here.
- Following downloads of same file goes at full speed.
How can this behaviour be disabled? Is it needed at all? Is this cache? This is quite annoying if you never redownload those files and if those files are quite big, as you are always getting half the speed that you should have.
Expected behavior
It should download at full speed the very first time, not needing to download a file previously to get full download speed.
Installation method
Community Docker image
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.1
Web server
Apache (supported)
Database engine version
PostgreSQL
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
Default installed apps, any installed.
Nextcloud Signing status
No response
Nextcloud Logs
No response
Additional info
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file, test, or code entry point is identified. Start by reproducing the first-versus-following download behavior with the official Helm/Apache setup and inspect Apache processes with iotop; done means the extra reads, delayed start, and reduced first-download speed have a confirmed cause and verified resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- apache, docker, kubernetes, php, postgresql
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100