• Resolved atlinstructional

    (@atlinstructional)


    I am having an issue with file downloads sent by PHP fopen or cURL when LiteSpeed Cache is enabled.

    The mime type and content type seem to be getting mixed up or lost, and the size of downloaded files is increasing by up to 50%. This is causing a variety of behaviors such as browsers adding an HTML extension to the actual file extension (filename.pdf.html, filename.jpeg.html, etc.), opening a “Save as” dialog instead of the intended forced download, or opening blank browser tabs when the download link is clicked.

    If LiteSpeed Cache is disabled, the forced downloads work properly on all devices and browsers. I’m wondering if anyone has any thoughts as to what could be causing this.

    Thanks for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support qtwrk

    (@qtwrk)

    have you tried exclude that specific download URL from being cached/optm’ed ?

    Thread Starter atlinstructional

    (@atlinstructional)

    Yes, download URLs are excluded.

    After some further testing I have learned that the reason PDF and JPEG files are being inflated in size and assigned an HTML extension is because the page source from the actual site is being added to the downloaded file. For example, if I open one of the inflated JPEGs with the HTML extension in a browser, then view the page source, I see garbled characters representing the image, followed by the fully legible page source.

    This issue is only occurring when LiteSpeed Cache is enabled. The fopen forced download script is being initiated by a PayPal plugin called WP Express Checkout. I think there must be a serious conflict between this plugin and Litespeed cache. I have made them aware of the issue as well.

    Plugin Support qtwrk

    (@qtwrk)

    if (strpos($_SERVER['REQUEST_URI'], "xxx") !== false){
    define( 'LSCWP_V', 1 );
    }
    

    try add this at top of your wp-config.php , next line after <?php , replace xxx to your URI , partial match also works

    see how it goes

    Thread Starter atlinstructional

    (@atlinstructional)

    That had no effect, but after some more checking I was able to determine that the problem is not specific to the LiteSpeed Cache plugin. The same issues exist with any cache plugin on the LiteSpeed server. There are no issues when caching is disabled on this server, and no issues with caching on non-LiteSpeed servers.

    For purposes of saving time, I think I’ll look around for another forced download script known to work on this server.

    Thanks for your replies.

    Plugin Support qtwrk

    (@qtwrk)

    Thread Starter atlinstructional

    (@atlinstructional)

    That was helpful. The download issues were resolved after adding the following:

    header(“X-LiteSpeed-Location: /wp-content/uploads/files/$file_name”);

    Thank you for your assistance with this.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘File Download Issues’ is closed to new replies.