kovshenin / surge

Surge is a very simple and fast page caching plugin for WordPress.
GNU General Public License v3.0
156 stars 11 forks source link

Support hosts that disable fpassthru() #41

Open avdi opened 4 months ago

avdi commented 4 months ago

Cloudways disables fpassthru(), and some cursory research indicates that others such as Flywheel do as well.

I put this dreadful kludge in my cache-config.php but it might be nice if Surge detected and coped with a missing fpassthru():

function fpassthru($stream) {
    echo stream_get_contents($stream);
}
kovshenin commented 2 months ago

Thanks @avdi! I'll look into this more.

I spoke with a few hosting providers that disabled fpassthru a couple of years ago and none of them had a good reason other than "probably because a similarly named passthru is disabled". Worth reaching out to support to ask about it and possibly enabling it, but I will definitely look into stream_get_contents to see if it's a good fit/alternative.

avdi commented 2 months ago

Thanks so much! My understanding is that stream_get_contents will never be as performant as fpassthru, so it's probably best to keep fpassthru as the default when it's available. But having the alternative would be nice!

I spoke with a few hosting providers that disabled fpassthru a couple of years ago and none of them had a good reason other than "probably because a similarly named passthru is disabled". Worth reaching out to support to ask about it and possibly enabling it, but I will definitely look into stream_get_contents to see if it's a good fit/alternative.