Home > Web Front-end > HTML Tutorial > How to use Server-Sent? Summary of Server-Sent instance usage

How to use Server-Sent? Summary of Server-Sent instance usage

巴扎黑
Release: 2017-06-14 17:00:57
Original
2488 people have browsed it

Simple sequence diagram of traditional WEB application communication: Most of the current Web Apps have Ajax, as shown below: HTML5 has a Server-Sent Events (SSE) function that allows the server to push data to the client. (usually called data push). Based on data push, when the data source has new data, it is sent to the client immediately without waiting for the client request. This new data may be the latest news, latest stock quotes, chat messages from friends, weather forecasts, etc. The functions of data pull and push are the same, and users get new data. But data push has some advantages. You may have heard that Comet, Ajax Push, Reverse Ajax, HTTP Streaming, WebSockets and SSE are different technologies. Probably the biggest advantage is low latency. SSE is used by web applications to refresh data without requiring any action from the user. You may have heard of HTML5 WebSockets, which can also push data to the client. WebSockets is a more complex technology to implement the server side, but it is really all-in-one

1. HTML5 supports server-sent events

How to use Server-Sent? Summary of Server-Sent instance usage

Introduction: HTML5 supports server-sent events (Server-Sent Events) )-One-way messaging data push (C# example)

2. Html5 server-side push Server-Sent Event

How to use Server-Sent? Summary of Server-Sent instance usage

Introduction: Server-sent Events (Server-sent Events) are HTML 5 A component of the specification that can be used to push data from the server to the browser in real time. Compared with similar COMET and WebSocket technologies, server push events are simpler to use and require less changes on the server side. For some types of applications, server push events are the best option.

3. HTML 5 server-sent events

How to use Server-Sent? Summary of Server-Sent instance usage

Introduction: HTML5 server-sent events allow web pages to get updates from the server.

4. javascript - h5 has Server-sent Events, how to write it on the PHP side?

Introduction: {code...} I wrote it like this (part of the code was copied). The problem is that every time the front end establishes a connection, PHP can only return data once. If you want the next data, rely on this line self::sendMsg('','','',100);//How many milliseconds No data, reconnect, this line will make the front end...

5. javascript - How to get updated data from the database when using Server-Sent Events?

Introduction: I can think of two ways: 1. Get the data in the most recent period, and return the data if available; but this time period is not easy to set, Chrome can use the last 3 seconds, but Firefox uses the last 5 Seconds, if it is set to 3 seconds, Firefox often cannot retrieve it; if it is set to 5 seconds, Chrome will retrieve duplicate data. 2. Second...

6. How to configure Server-Sent Events under nginx?

Introduction: Using php+js to implement server push can take effect in the wamp environment, but when it is moved to nginx under Linux, it cannot be used. Is it an environment configuration problem? How to configure it? The following is the relevant code server-side php code: {code...} Front-end js: {code...}

【Related Q&A recommendations】:

Questions in html5 push

javascript - h5 There is Server-sent Events, how to write it on the PHP side?

php - How to configure to use Server-Sent Events under nginx?

javascript - How to get updated data from the database when using Server-Sent Events?

javascript - How to use Server-Sent Events in node.js

The above is the detailed content of How to use Server-Sent? Summary of Server-Sent instance usage. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template