nlkDuy
nlkDuy

Reputation: 3

Realtime between Laravel and MySQL

I am developing a Laravel app connect to MySQL database, and I want to show the realtime records on Laravel when database has changed. I used to try Ajax, but I think that is not the best way. Can anyone give me a method?

Upvotes: 0

Views: 1029

Answers (1)

Cloud Soh Jun Fu
Cloud Soh Jun Fu

Reputation: 1512

You can use AJAX to achieve it by requesting Laravel every 5 seconds also. However, it will increase the load of the network and the heaviness of back-end. There are many useless requests made if there is no update on the server.

A better approach is to broadcast the changed data to the client side when the server receives an update. Or, broadcast to client-side and ask the client(mostly Javascript) to make the AJAX request to the back-end.

Usually, you have to set up a Redis or you can use third-party service like Pusher.

Upvotes: 2

Related Questions