0

first of all.. sorry for my english, i'll try my best!

I have a web application where i show info about Data stored in my Mysql. I Would like to make it more dynamic and if some new information appear in my DB then update my web content without a refresh. I was thinking about Ajax. Every minute send an ajax function asking for some new data... but it's not a good idea 'cause it can be stressing for my server.

What's the best way to do it?

Thanks a lot for your time!

  • Your post will most likely be closed becaues its too broad. Stackoverflow is more suited for exact questions and exact answers. Anyways you have two options: 1. As you said - check every minute or so for refreshing content, 2. Take a look at this answer: https://stackoverflow.com/a/10029326/3223157 that describes your possibilities – Xatenev Nov 14 '17 at 10:27
  • Thanks a lot, i'll take a look as you said <3 – Marc Zinni Arranz Nov 14 '17 at 10:29

1 Answers1

0

You could use something like Firebase which automatically pushes data to the client when changes occur in the backend database, but that means that you would have to store all your data in Firebase instead of in your Mysql database.

Apart from a service like that, one option is to use an ajax call to fetch new data, but only when new data is available. I don't know how your data is structured, or what kind of data it is, but one solution to minimize the load on your server is to have a database table with a timestamp column that's updated every time relevant data is changed, added or deleted in your database. Use ajax to fetch only this timestamp every minute and if the timestamp has changed since you last checked it, make another ajax call to fetch the actual data.

rodskagg
  • 3,827
  • 4
  • 27
  • 46