WooCommerce allows you to start selling products really quickly especially virtual downloadable products. It’s a mature e-commerce WordPress plugin that you can use to start selling digital goods right away.

If you’re selling digital products such as pdf, zip, mp3, epub files etc you may encounter an annoying error such as 0 byte downloads. The customer clicks on a download link and the browser offers a file name called “download” which is empty/0 bytes.

The issue is related how you’ve configured your ecommerce store’s File download method of downloadable products in:

WooCommerce > Settings > Products > Downloadable products

woocommerce settings downloadable products file download method

In our case the 0 byte virtual product download was caused because we’ve had  WooCommerce’s  File download method to be Force Downloads (default) and the download link was actually forcing downloads. WooCommerce was trying to read from a remote file which was offered for download.

Forcing downloads means that the browser is instructed to offer the file for download regardless if it can render it. For example Firefox can render a PDF file but we don’t necessarily want that. We want to be able to save the file on our computer and then decide which program to use it to open it or maybe copy it to Dropbox and check it later. When a file is opened in the browser we may forget to actually save it on our computer.

WooCommerce has several ways to deliver downloadable products.

For more info check: https://docs.woocommerce.com/document/digital-downloadable-product-handling/ 

One of them is Force download which is a good way to deliver the files in most cases if the files are small and they reside on the same server.

If you’re delivery files that reside on another server such as dropbox you’ll have to use a different way.

Such as redirect. This option works but reveals the direct download link.

Please can get to that direct link by accessing their download histry and bypass the WooCommerce download protection that you may use (e.g. limit the downloads to 10 and up to 5 days after purchase).

The 3rd option that WooComemrce offers for handling downloads is using some x-accel which is basically good for delivering large files which are stored on the same server. The web server (apache, nginx) needs to support this otherwise it won’t work. If the server supports this the file delivery is optimized because there are “fewer cooks in the kitchen” when handling the download.