How can I store real-time webpage data in a file and use php for real-time webpage? if the file changes, I will immediately update the current webpage. how can I achieve this? The previous idea was to make a round-robin request in js every second. if the file changes, it will be reloaded. I think this is not good. this requirement must be truly "how to make real-time web pages in real time ?"
Data information is stored in a file and php is used as a real-time webpage. if the file changes, it immediately updates the current webpage. how can this problem be solved? The previous idea was to make a polling request in js every second. if the file changes, it will be reloaded.
------ Solution --------------------
This requirement must be truly "real-time" in two aspects:
1. instant file update notification.
2. the server can send data to the client (browser) in real time ).
First, instant notification of file updates. what you want is to scan the last update time of the file cyclically. in this step, the method you want cannot be implemented in real time. To achieve real-time, we must use the system's time-driven. For example, linux 2.6 kernel inotify. Write a program in c and run a process. After receiving this notification, modify the php source code.
Server pushing is actually a response data loop from the server to the client during an http interaction between the client and the server. Most of the information on the Internet is general. I would like to sum up that, in fact, it is not that complicated.
1. modify the buffer of the web server.
2. disabling the web server will take the initiative to control the buffer module, such as gzip.
3. the buffer size of the browser needs to be broken. for example, each time the program fills in some spaces in the response data, the other data reaches the buffer size of the browser. For example, ie is 1024 bytes.
It works well on apache, and sometimes it is strange on nginx. some of my friends reported that they could not succeed, but I succeeded in nginx + chrome on the local machine.
Next, you should consider how to combine these two points.
------ Solution --------------------
If the page and the program are not on the same server, you can push the page, that is, execute the script program on server A to generate the latest page, and then use the shell script to move the latest page to server B.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service