Home > Enterprise >  Build a PHP api that doesn't require constant requests
Build a PHP api that doesn't require constant requests

Time:04-03

So I am working to build an IP in PHP. I'm using Fetch method in Javascript to get the response. When something changes on server, it need to send a response to JS. To do this I was using setInterval() and repeat each second. These are too much requests. Is there any better way to do it?

CodePudding user response:

You can make a websocket server easily which emits the client to update the data (also you can emit the updated data as well).

As far as I know react.js does the same thing in development mode, you should check it out, probably it will help a lot.

  • Related