Menu

Why I never store downloaded files on my own server
πŸ“°

Why I never store downloaded files on my own server

DEV Community: phpΒ·Mobeen AhmedΒ·9 days ago
#1h7trh80
#devto#dev#file#visitor#disk
Reading 0:00
15s threshold

When I rebuilt my video downloader as a plain PHP site on shared hosting, the first design decision was the simplest one: my server never keeps the video. A visitor pastes a link, my code finds the file, and the file travels straight to them. Nothing is saved on my disk, not even for a minute.

It sounds obvious, but it is a deliberate choice, and it shapes everything else in the codebase. Here is why I made it, and what it costs.

The disk would fill up anyway

Shared hosting gives me a small slice of disk and a hard inode limit. One viral video is a few hundred megabytes; a busy afternoon of downloads would be gigabytes. If I stored every file, I would need a cleanup job, a quota check, and a plan for when the disk fills at 2 a.m. β€” and a full disk on shared hosting does not just break downloads, it breaks the whole site.

So there is no uploads/ folder, no temp directory filling with MP4s, and no cron job deleting old files.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.