How to force download of big files without using too much memory?

后端 未结 6 1200
清歌不尽
清歌不尽 2021-02-15 06:33

I\'m trying to serve large zip files to users. When there are 2 concurrent connections, the server runs out of memory (RAM). I increased the amount of memory from 300MB to 4GB (

6条回答
  •  臣服心动
    2021-02-15 07:00

    You're sending the contents ($data) of this file via PHP?

    If so, each Apache process handling this will end up growing to the size of this file, as that data will be cached.

    Your ONLY solution is to not send file contents/data via PHP and simply redirect the user to a download URL on the filesystem.

    Use a generated and unique symlink, or a hidden location.

提交回复
热议问题