Search code examples
phphttphttpshttp-headersob-start

ob_start difference between https and http?


Is there a different behaviour for ob_start, ob_end_flush, ob_end and ob_flush in https compared to http?

I have read the posts about difference between http and https:

Difference between http and https

Difference between HTTPS and SSL

as I have read this one about ob_start & headers:

Showing error pages when sending header with header() function

but I do not find the answer I need.

My Case:

I am flushing a loading image with ob_start on two websites. They are using the exact same code. The only difference is the protocol - one is http and one is https.

The http one acts fine

The site using http outputs the image and will then continue with the script.

The https one acts different

The site using https outputs the image always after the script has been completely processed.

Thanks. I am glad for any hint.


Solution

  • I see two possibilities:

    • HTTPS sends data in blocks (records), which may be 16KB large. If your image is smaller than that, the server may wait for more data before sending a complete block.

    • Your HTTPS is implemented by a reverse proxy, and the proxy waits for the entire response to be sent before forwarding anything.

    If you're using php-fpm, try http://php.net/manual/en/function.fastcgi-finish-request.php

    If you're using nginx, try http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering