1

I have a client who's selling MP3's on his Mage site. These MP3's are pretty big, around 90MB, and when the download link is click in the account area there can be up to a 2 minute delay before the download actually starts. During the delay, the browser shows "Waiting for www.domain.com...".

I've tried a small file, a couple of kb, and that works quickly, so its obviously something to do with file size.

However, I've replicated the file download outside of Magento and the download starts immediately, even with the 90mb file. Does anyone know what Magento could be doing to cause this delay?

The download script is split between the following 2 files;

Mage/Downloadable/controllers/DownloadController.php::linkAction() Mage/Downloadable/Helper/Download.php

I can't see it doing anything out of the ordinary though. Obviously, Magento does A LOT of checks, but those shouldn't change depending on file size.

Bit of a vague one, any help though would be much appreciated.

Thanks,

1 Answer 1

3

As you can see in Mage_Downloadable_DownloadController, the last line of the _processDownload method is $helper->output();

The output function of Mage_Downloadable_Helper_Download reads the file stream and prints it.

public function output() {
  $handle = $this->_getHandle();
  if ($this->_linkType == self::LINK_TYPE_FILE) {
    while ($buffer = $handle->streamRead()) {
      print $buffer;
    }
   }
   ...
}

This might be the reason why it slower when your file download is served via Magento.

3
  • Would this have to wait until the whole file has loaded before it prints the file to the browser? Would that be an alternative to readfile()?
    – thebluefox
    Oct 17, 2014 at 12:54
  • According to the code: As the whole file is read as stream and printend: yes, seems legit. I'm not sure at which point exactly the download starts. Oct 17, 2014 at 13:00
  • Maybe you just put a Mage::log in to track? Oct 17, 2014 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.