2

All of the zip files downloadables from my site are being corrupted.

Looking for answers online I always find the same result: To edit htaccess because it is double compressing the files. I'm quite certain this is the problem as if I go to the link directly it works, and if I upload a zip file uncompressed, it works.

I have tried editing my htaccess to match the code below but it does not seem to work!?

• Do I need to place an htaccess file with that right in the /downloadable directory?

• Could I use an external link as a download, i.e through dropbox or something?

    # php_flag zlib.output_compression on # problems with downloadable content

...
...
...

# Insert filter on all content
### SetOutputFilter DEFLATE # problems with downloadable content
# Insert filter on selected content types only
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
  • 1
    Are the sizes of the downloaded files ok? If you try to zip too much, you might get a out of memory error and only this error is in the zip, try to open it with an editor, if it is only a few kB big. – Fabian Blechschmidt May 8 '13 at 7:46
1

If this is happening to direct downloads of zip files, it's definitely the rules in the .htaccess or apache config. You'll want to update this section of your .htaccess file:

# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary

with this:

# Don't compress images or zip files
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|zip)$ no-gzip dont-vary

Then make sure that you DO NOT have the blanket SetOutputFilter DEFLATE rule set and are only using the AddOutputFilterByType rule to enable the compression. The latter one will turn it on based on mime-type, whereas the first enables it across the board on everything.

After you do this, the server should definitely NOT be double compressing the data when serving files resources where the URL ends in .zip by merit of the mime-type as well as the URI matching the pattern.

If this is happening only on downloads of zip files from purchased downloadable products, and you've done both of the things mentioned above, then you'll need to verify that the Content-Type: application/zip header is being sent with the download since Magento essentially proxies the content to the browser in a data stream and sets the mime-types itself.

The easiest way to check the headers is to use curl like this:

$ curl -sv http://mage.dev/1.7/downloadable/download/linkSample/link_id/1/ > /dev/null
* About to connect() to mage.dev port 80 (#0)
*   Trying 127.0.0.1...
* connected
* Connected to mage.dev (127.0.0.1) port 80 (#0)
> GET /1.7/downloadable/download/linkSample/link_id/1/ HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: mage.dev
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Wed, 08 May 2013 01:55:36 GMT
< Server: Apache/2.2.22 (Unix) PHP/5.3.14 mod_ssl/2.2.22 OpenSSL/0.9.8o
< X-Powered-By: PHP/5.3.14 ZendServer/5.0
< Set-Cookie: frontend=v8qacn7t586ckfljbibnm4ea82; expires=Wed, 08-May-2013 02:55:36 GMT; path=/1.7; domain=mage.dev; HttpOnly
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: must-revalidate, post-check=0, pre-check=0
< Pragma: public
< Content-Length: 905467
< Content-Disposition: inline; filename=lame.zip
< Content-Type: application/zip
< 
{ [data not shown]
* Connection #0 to host mage.dev left intact
* Closing connection #0
  • hi i have the same probelm with downloadproducts, since the download is processed in php you fix won't work, is it possible to disable gtzip for urls which start with downloadable/download/link/id/ ? – wutzebaer Aug 14 '14 at 9:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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