Mobile app version of vmapp.org
Login or Join
Odierno851

: How to make files (hosted on free hosting website) ready for 'fast download'? I have hosted some files on a free website hosting account. I am used to transferring my files via an FTP client

@Odierno851

Posted in: #Download #Server #WebHosting

I have hosted some files on a free website hosting account.

I am used to transferring my files via an FTP client and it works well. But sometimes I need to download the files via a web browser. Here is where I face some problems. The most important thing for me is the time for starting download or the time for the file to be downloaded.

Is this caused by the specification of the server? Or is there some configuration that I have to set? Or may be it is caused by the limit of download speed - is 'download speed' affected by the website's bandwidth?

I'm really new to web hosting management, so forgive me if the topic is too basic to ask.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Odierno851

1 Comments

Sorted by latest first Latest Oldest Best

 

@Courtney195

Time till start download

The startingtime depends (mainly) on:
- Time it takes to run the PHP code (this should take little time)
- The time it takes before the first data is send

The latter one is the main contributor, you want to send (some) data as fast as you can. If you echo a file_get_contents() of a file, you would have to wait untill all the data is send to the browser (essentially the whole download it will blank, and at the end the whole file will be complete in 1 go). What you want is to send it in chucks, send small pieces real fast.

Examplecode which sends 1024 bytes per itteration:

// OPENING THE FILE
$file = fopen($filepath, "r");
$bufferlength = 1024;
while (!feof($file)){
// READ A BUFFER SIZE OF THE FILE
$buffer = fread($file, $bufferlength);
echo $buffer;
$buffer = "";
flush(); // THIS IS ESSENTIAL FOR LARGE DOWNLOADS
}
fclose($fp);


The max speed here is: $bufferlength*(itterations in 1 sec) bytes/sec.
You could use algorithms to make it send small chunks in the beginning, increasing in size the further it progresses.

Time to complete download

This is influenced by the code above, but that will be fast enough for 99% of the cases.
The main cause here is bandwidth. Cheap hosts are not premium hosts, you don't get much bandwidth. The speed at which you can upload is limited, and if multiple users want to download something, this will get shared amongst them.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme