Enable Server-Side Events (SSE) / Streaming with PHP by default

Issue Summary

Local doesn’t work with Server-Side Events (SSE); I have tried both with Nginx and Apache. It might be the default server settings? If you find a way to make it work with SSE, a lot of users would be happy with this (lot of then don’t know the technical details but they need streaming for parts of their WordPress).


I made a PHP script that you can simply drop in a fresh WordPress install, then simply call it directly (WordPress doesn’t matter here). This is the one: SSE (Server-Sent Events) with PHP and JS / Streaming with PHP · GitHub.

I have nothing this thread here: Server Sent Events. But it was closed, without any answer.

Hi @TigrouMeow!

Thank you for coming and sharing your insight and script! I’ve changed your post to a Feature Request. So if other users are interested in making this more compatible with Local they can vote and comment. We use these to be able to gauge interest in future enhancements, so we appreciate the contribution!

Thank you! By the way, it works with Kinsta and their alternative to Local called “DevKinsta”. It also work with Siteground but doesn’t with WP Engine.

Many people will want this, though they don’t technically know what it means, they will never ever vote for this here, but they will switch hosting service based on recommendations; for example, if it doesn’t work with Flywheel, I will have to recommend another hosting for the users of my plugin (currently 30,000 users). Please consider it, it’s not only a feature for Local, it’s more.

1 Like

Thanks Jordy to think about all the users who are just managing through :slight_smile: Please, make it work widely on various hosts… just to think about the hassle to change host I want to cry… But would certainly do it nonetheless!
Again thanks for all your plugins, and more particularly AI Engine and its developments.

Thank you again @TigrouMeow! I’ll share this with our Devs after the weekend to try and gain some more insight.

1 Like

Hey @TigrouMeow - thanks for starting this feature request!

The engineering team talked it over, and this is possible in Local today. The nginix configuration just needs to be updated and you’re good to go. Here are the steps we took to see it working:

  1. Using Site Domains router mode in Local, Create a new site
  2. Add your sse.php script to ~/Local Sites/sitename/app/public/sse.php
  3. Navigate to that script in the browser: http://sitename.local
  4. Note that the script waits for a bit, then outputs all the numbers. The intended behavior is to have each number show up one at a time, about a second apart
  5. Edit /Applications/Local.app/Contents/Resources/extraResources/router-config/nginx.conf and add the below nginx config lines:
    proxy_set_header Connection '';
    proxy_http_version 1.1;
  6. Quit Local and restart it (this regenerates the router config file)
  7. Navigate to the script again in the browser (http://sitename.local) and note that the numbers come in, one at a time.

Shared with Zight

We can evaluate changing this default behavior, but we’ll have to do some research on any potential side effects… the good news is that with some quick changes, users can have this working in Local pretty easily!

1 Like

Thank you! It’s awesome :slight_smile: Normally, it shouldn’t affect anything else, except streaming (which, let’s be honest, is rarely used with PHP). But it works! I also heard from one of my users that you cab also deploy this change for specific users of Flywheel, which is really cool. WPEngine is a bit behind on this though, you are way more reactive haha! (apparently it’s not the same team)

1 Like

Ha, it is a big company! But we’ll follow up with our friends on the WP Engine platform and see what we can do.

I was doing some additional troubleshooting on this, just because I was curious. I did find that if your site is in localhost mode (as opposed to site domains), it seems SSE works out of the box without any changes (although, I’m not 100% sure why)… but it was working for me! Please pass this along to your users if they’re asking :slight_smile:

We’ll keep digging on that change as a default. Thanks for bringing this to our attention!

Great! Let me know if I can help in any way. Meanwhile, I was able to improve AI Engine (AI Engine: ChatGPT Chatbot, Content Generator, GPT 3 & 4, Ultra-Customizable – WordPress plugin | WordPress.org) thanks to that change! That’s going to motivate a lot of users to move to Flywheel for sure. Thanks a lot :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.