A kind of resource regeneration method and device
Technical field
The present invention relates to Internet technical fields, and in particular to a kind of resource regeneration method and device.
Background technology
In the prior art, it to realize that client demand resource refreshes in real time, need client periodically constantly to service
Device has asked whether new resources update.When server does not generate resource updates, client still constantly polling server,
In this way, server needs to handle these invalid polling messages in large quantities, client and server uses Hyper text transfer
(HTTP) agreement connects, user end to server poll, after server response, disconnects, next client poll services again
When device, connection need to be established again, and server resource and bandwidth resources is so caused to waste.
Invention content
Present invention seek to address that problem as described above.The object of the present invention is to provide a kind of resources for solving problem above
Update method and device.
The present invention provides a kind of resource regeneration methods, including:
Intermediate equipment from multiple client receive resource load request, according to resource load request determine client identification and
The target resource identifier of the resource load request determines the resource of resource on the server corresponding to each target resource identifier
Storage address records correspondence, and the correspondence includes the corresponding resource storage address of same target resource identifier and hair
Give the client identification of each client of this target resource identifier;
Intermediate equipment timing inquires whether each resource storage address generates resource updates to server, from server
In reception resource storage address after newer resource, the correspondence is inquired, determines that this resource storage address is corresponding described
Each client identification sends newer resource according to each client identification inquired to corresponding client.
Above-mentioned resource regeneration method also has the characteristics that:
Long connection is maintained between the intermediate equipment and each client.
Above-mentioned resource regeneration method also has the characteristics that:
The agreement of the long connection is the agreement for the long connection that the browser of the client is supported.
Above-mentioned resource regeneration method also has the characteristics that:
The agreement of the long connection is web socket agreement.
Above-mentioned resource regeneration method also has the characteristics that:
Each client identification that the basis inquires sends newer resource to corresponding client:According to inquiry
Each client identification arrived is to newer resource described in corresponding client transmitted in parallel.
The present invention also provides a kind of resource updates devices, including:
Request receiving module, for receiving resource load request from multiple client;
Correspondence maintenance module, for determining client identification and the resource load request according to resource load request
Target resource identifier, determine the resource storage address of resource on the server corresponding to each target resource identifier, record pair
It should be related to, the correspondence includes the corresponding resource storage address of same target resource identifier and this target resource identifier of transmission
Each client client identification;
Poller module inquires whether each resource storage address generates resource updates for timing to server;
Resource receiving module, for receiving newer resource in resource storage address from server;
Enquiry module determines corresponding each client mark described in this resource storage address for inquiring the correspondence
Know;
Sending module, for sending newer resource to corresponding client according to each client identification inquired.
Above-mentioned resource updates device also has the characteristics that:
Long connection is maintained between the intermediate equipment and each client.
Above-mentioned resource updates device also has the characteristics that:
The agreement of the long connection is the agreement for the long connection of foundation that the browser of the client is supported.
Above-mentioned resource updates device also has the characteristics that:
The agreement of the long connection is web socket agreement.
Above-mentioned resource updates device also has the characteristics that:
Sending module is additionally operable to according to each client identification for inquiring to the corresponding newer money of client transmitted in parallel
Source.
The present invention can effectively save the process resource of server, improve the process performance of server, and save bandwidth
Resource.The present invention saves client-side because frequently establishing connection caused by poll also using the connection type of long connection
Processing procedure.
Description of the drawings
The attached drawing for constituting the part of the present invention is used to provide further understanding of the present invention, schematic reality of the invention
Example and its explanation are applied for explaining the present invention, is not constituted improper limitations of the present invention.In the accompanying drawings:
Fig. 1 is a kind of flow chart of a resource regeneration method provided according to an embodiment of the invention;
Fig. 2 is a kind of illustrative diagram of a resource regeneration method provided according to an embodiment of the invention.
Fig. 3 is a kind of structural schematic diagram of the two resource updates devices provided according to an embodiment of the invention.
Specific implementation mode
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is
A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art
The every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.It needs
Illustrate, in the absence of conflict, the features in the embodiments and the embodiments of the present application mutually can be combined arbitrarily.
A kind of resource regeneration method of detailed description of the present invention exemplary embodiment and device below in conjunction with the accompanying drawings.
Embodiment one
Fig. 1 is the flow chart for showing an a kind of resource regeneration method provided according to an embodiment of the invention.Referring to Fig.1,
The method includes:
Step 101, intermediate equipment receives resource load request from multiple client, and client is determined according to resource load request
The target resource identifier of end mark and resource load request determines resource corresponding to each target resource identifier on the server
Resource storage address records correspondence, and correspondence includes the corresponding resource storage address of same target resource identifier and hair
Give the client identification of each client of this target resource identifier;
Step 102, intermediate equipment timing inquires whether each resource storage address generates resource updates to server, from clothes
In device reception resource storage address of being engaged in after newer resource, correspondence is inquired, determines the corresponding each visitor of this resource storage address
Family end identifies, and newer resource is sent to corresponding client according to each client identification inquired.
Long connection is maintained in above-mentioned steps 101, between intermediate equipment and each client, the agreement of the long connection is visitor
The agreement for the long connection of foundation that the browser at family end is supported, for example, using the web socket triggered based on event
(WebSocket) agreement establishes long connection.
In above-mentioned steps 102, according to each client identification inquired to the corresponding newer money of client transmitted in parallel
Source.
In above-mentioned steps 102, as shown in Fig. 2, intermediate equipment is built with server by utilizing Hyper text transfer (HTTP) agreement
Vertical connection, intermediate equipment timing (such as every 100 milliseconds) inquire whether each resource storage address generates resource updates to server,
It is received in resource storage address after newer resource from server, the correspondence established in query steps 101 determines this money
The corresponding each client identification of source storage address, it is newer to the transmission of corresponding client according to each client identification inquired
Resource.
Embodiment two
Fig. 3 is the structural schematic diagram for showing the two a kind of resource updates devices provided according to an embodiment of the invention.Reference
Fig. 3, described device include:
Request receiving module 301, for receiving resource load request from multiple client;
Correspondence maintenance module 302, for determining that client identification and the resource load according to resource load request
The target resource identifier of request determines the resource storage address of resource on the server corresponding to each target resource identifier, note
Correspondence is recorded, the correspondence includes the corresponding resource storage address of same target resource identifier and this target resource of transmission
The client identification of each client of mark;
Poller module 303 inquires whether each resource storage address generates resource updates for timing to server;
Resource receiving module 304, for receiving newer resource in resource storage address from server;
Enquiry module 305 determines the corresponding each client identification of this resource storage address for inquiring correspondence;
Sending module 306, for sending newer resource to corresponding client according to each client identification inquired.
Long connection is maintained in above-mentioned request receiving module 301, between intermediate equipment and each client, the long connection
Agreement is the agreement for the long connection of foundation that the browser of client is supported, for example, using the web socket triggered based on event
(WebSocket) agreement establishes long connection.
Above-mentioned sending module 306 is additionally operable to each newer resource of client transmitted in parallel.
The present invention can effectively save the process resource of server, improve the process performance of server, and save bandwidth
Resource.The present invention saves client-side because frequently establishing connection caused by poll also using the connection type of long connection
Processing procedure.
Descriptions above can combine implementation individually or in various ways, and these variants all exist
Within protection scope of the present invention.
One of ordinary skill in the art will appreciate that all or part of step in the above method can be instructed by program
Related hardware is completed, and described program can be stored in computer readable storage medium, such as read-only memory, disk or CD
Deng.Optionally, all or part of step of above-described embodiment can also be realized using one or more integrated circuits, accordingly
Ground, the form that hardware may be used in each device/unit in above-described embodiment are realized, the shape of software function device can also be used
Formula is realized.The present invention is not limited to the combinations of the hardware and software of any particular form.
It should be noted that herein, the terms "include", "comprise" or its any other variant are intended to non-row
His property includes, so that article or equipment including a series of elements include not only those elements, but also includes not having
There is the other element being expressly recited, or further includes for this article or the intrinsic element of equipment.Do not limiting more
In the case of system, the element that is limited by sentence " including ... ", it is not excluded that including the element article or equipment in
There is also other identical elements.
The above examples are only used to illustrate the technical scheme of the present invention and are not limiting, reference only to preferred embodiment to this hair
It is bright to be described in detail.It will be understood by those of ordinary skill in the art that can modify to technical scheme of the present invention
Or equivalent replacement should all cover the claim model in the present invention without departing from the spirit of the technical scheme of the invention and range
In enclosing.