Can't load multiple PHP pages at once

Discussion in 'Install/Configuration' started by Banana Lord., Dec 2, 2012.

  1. Banana Lord.

    Banana Lord. New Member

    I have a site that is supposed to serve files via a PHP page. If this PHP page is serving a file (ie. a 20MB file), nothing else will load at the same time. It waits for the current file to finish loading before loading the next one (and also means the site doesn't work in another tab). Is there some way to fix this? Thank you.
  2. NiteWave

    NiteWave Administrator

    how about open 2nd file in another browser ? can download 2 files at the same time ?
  3. Banana Lord.

    Banana Lord. New Member

    While downloading the file served by PHP in Chrome I cannot access any pages on the site in Chrome, but, while downloading a PHP-served file in Chrome I can access the site from Internet Explorer. Visa-versa for Internet Explorer.

    I also have a friend that confirms the issue
  4. NiteWave

    NiteWave Administrator

    please PM the website's domain name and brief the test steps, I test in my browser.
  5. NiteWave

    NiteWave Administrator

    it's PHP script which limit the downloads.

    looks like the PHP script use the session cookie to archive this goal.

    in firefox, open a tab, can access a URL to download a 50M file,
    when open 2nd tab, access same URL, it'll wait until 50M file download completed.
    if open the URL in another browser, it starts downloading without wait.

    then back to firefox, open firebug+firecookie, delete all cookies, then can open 2nd tab to download same file at the same time.

    so it's not relating to web server, but PHP script do it purposely.
  6. Banana Lord.

    Banana Lord. New Member

    Thanks for your help. It seems I can get around this by using the information on this page: http://www.litespeedtech.com/support/wiki/doku.php?id=litespeed:wiki:feature:internal_redirect

    I am a bit unclear as to how to use this header. In the PHP file that processes/handles the download, should I simply replace all of my current headers to force the download and just use header("X-LiteSpeed-Location: /path/to/my/file");

    Thanks
  7. webizen

    webizen New Member

    just replace 'Location: ...' with 'X-LiteSpeed-Location: /path/to/my/file'.
  8. Banana Lord.

    Banana Lord. New Member

    Thanks, but my code is as follows currently:

    [​IMG]

    Would I replace readfile with X-LiteSpeed-Location?
  9. NiteWave

    NiteWave Administrator

    should be, and you can comment out line 62-73.
  10. Banana Lord.

    Banana Lord. New Member

    Thanks, it seems to be working - but if I want to display image files I should use the readfile method, correct?
  11. NiteWave

    NiteWave Administrator

    if the image's suffic is jpg/png etc, I think still ok to use X-LiteSpeed-Location

    the X-LiteSpeed-Location is like redirect (but internal not external), pass this file to web server(here litespeed) to handle it. so if the file name is .jpg, web server will think it a jpeg image and generate proper headers for it.
  12. Banana Lord.

    Banana Lord. New Member

    Unfortunately my site doesn't retain the extension of the file on the disk (but does in the database) - is there any way to trick LiteSpeed into thinking it's a .jpg?
  13. NiteWave

    NiteWave Administrator

    I have an idea in your php script, create a temporary symbolic link to the file, like a.jpg, then "X-LiteSpeed-Location: /path/to/a.jpg". when download complete, delete a.jpg. or create a cron job, clean up these temporary soft link(a.jpg) which created 1 hours ago(for example).
  14. Banana Lord.

    Banana Lord. New Member

    Thanks, I'll give it a shot. Can I remove the symlink after the X-LiteSpeed-Location header? ie.

    header('X-LiteSpeed-Location: /files/tmp/temp.png');
    unlink('/files/tmp/temp.png');

    When using them in that order I receive the following error in LiteSpeed:

    detect loop redirection
    Last edited: Dec 6, 2012
  15. NiteWave

    NiteWave Administrator

    No, can't.

    since the temp.png not sent to user yet.
    the 1st line is to tell litespeed web server, "please send this file to user"

    maybe you have to
  16. Banana Lord.

    Banana Lord. New Member

    Thanks, I've got an idea for that now.

    I am using the symlink option to send files to the user via X-LiteSpeed-Location (with the extension), but it seems that extension was not sent with it.
  17. webizen

    webizen New Member

    make sure you can serve image file with extension directly (i.e., MIME type is supported) before serve via X-LiteSpeed-Location.

Share This Page