Detailed Description
The CDN is a layer of intelligent virtual network based on the existing Internet, and by placing node servers at each position of the network, a CDN system can guide a user request to a CDN node closest to the user according to network flow, network conditions and load conditions of each node, the distance to the user, response time and other comprehensive information in real time, so that the user can obtain required content nearby, the problem of network congestion is solved, and the response speed of web access initiated by the user is improved.
For any CDN system, the deployment location of the CDN node will generally fully consider the network conditions, traffic distribution, and other factors in the area where the CDN node is located, so as to achieve fast data transmission with the terminal of the user as much as possible. In addition, the CDN node usually runs in an IDC (Internet Data Center) room or a network device of a core network, and the speed of accessing other servers (e.g., a service end providing a certain service) is much faster than the speed of accessing the servers by a terminal in a local area.
In view of the above, embodiments of the present specification provide a new method for implementing Web access, where a terminal sends a request for a dynamic resource to a CDN node, and the CDN node obtains the dynamic resource requested by the terminal from a service server and returns the dynamic resource to the terminal, so that fast transmission between the CDN node and the terminal and fast transmission between the CDN node and the service server can be used, thereby greatly increasing the speed at which the terminal obtains the dynamic resource in Web access, facilitating smooth completion of a service process, and solving problems in the prior art.
In the embodiment of the present specification, the terminal and the CDN node, and the CDN node and the service server may access each other through a network. The terminal can be a mobile phone, a tablet Computer, a Personal Computer (PC), a notebook Computer, or the like; the CDN node or the service server may operate on one physical device, or may operate on two or more physical devices, and the physical devices cooperate with each other to implement each function of the CDN node or the service server in this embodiment of the present disclosure. The embodiments of the present specification do not limit the types of devices in which a terminal, a CDN node, or a service end is located, and the types, protocols, and the like of communication networks between the terminal and the CDN node and between the CDN node and the service end.
In the embodiment of the present specification, a flow of the implementation method for web access applied to a CDN node is shown in fig. 1, and a flow of the implementation method applied to a terminal is shown in fig. 2.
On the terminal, step 210, a page resource request is sent to the CDN node, where the page resource request is a request for dynamic resources.
On the CDN node, step 110, a page resource request sent by the terminal is received.
Embodiments of the present description apply to web products. The Web product includes Web pages for implementing one to multiple specific business processes or components of one to multiple specific business processes, and the Web pages may be pages for users to browse, pages capable of receiving user input, pages interacting with users, or other forms of pages, without limitation.
All domain names used by the web product to which embodiments of the present specification apply are deployed on the CDN system. These domain names are used to initiate access when a terminal is using the web product. According to the working principle of the CDN System, the IP address of the CDN node closest to the terminal at present will be used as a result of DNS (Domain Name System) resolution. Thus, requests initiated using the web product will be sent to the CDN node.
The same web product may store resources to be used in the network by means of multiple domain names. Thus, when the terminal makes a resource request in the web product, multiple domain names are often resolved, increasing the time delay for opening the web page. All resources of the web product can adopt the same domain name, the IP address of the CDN node is obtained by DNS analysis for one time, and then the address of the CDN node cached in the local can be used for initiating the request of the web product, so that the web access speed is accelerated.
And after the terminal obtains the address of the CDN node, sending a page resource request to the CDN node.
In embodiments of the present description, a page resource includes various information required to present a web page, including static resources and dynamic resources. In an actual application scenario, according to the system characteristics of the CDN, a page resource suitable for being delivered to a terminal by using a CDN mechanism may be used as a static resource, and other resources may be used as dynamic resources. For example, static resources may include page content data that is common to multiple users, infrequently changing, such as pictures, fonts, Cascading Style Sheets (CSS), js (javascript), and so on; the dynamic resources may include other resources than static resources in the page resources, such as service information that changes frequently over time, service data generated during the service progress of the web product, page content data that is different from user to user, and so on.
Depending on the specific page implementation of the web product, one or more resources required to render a web page may be static resources or dynamic resources, and more typically include both static and dynamic resources. When a user opens a web page in a browser of the terminal or performs an interactive operation on the web page, the terminal needs to obtain several resources required for presenting the next web page (the opened web page, or the web page with the interactive result, etc.). According to the implementation mechanism of the browser, the terminal respectively initiates a page resource request aiming at each required resource. Thus, the page resource request sent by the terminal is either a request for static resources or a request for dynamic resources.
On the CDN node, in step 120, after determining that the page resource request is a request for a dynamic resource according to the predetermined resource type rule, the dynamic resource requested by the terminal is obtained from the service end.
After receiving the page resource request of the terminal, the CDN node determines whether the page resource is a request for dynamic resources or a request for static resources according to a predetermined resource type rule. If the requested resource is a dynamic resource, the CDN node initiates communication for acquiring the dynamic resource to the service server according to the page resource request of the terminal. The service end returns the dynamic resource requested by the service end (namely, the terminal request) to the CDN node.
In the prior art, a service server provides a way for acquiring dynamic resources to a terminal, and a CDN node can request the dynamic resources from the service server in the same way. The service server may also provide dynamic resources of the user to the CDN node in a manner different from that of the terminal between the service server and the CDN node, and embodiments of the present specification are not limited as long as the CDN node can obtain the dynamic resources required by the terminal from the service server.
The predetermined resource type rule can be determined according to factors such as the dividing mode and the management mode of dynamic resources and static resources in an actual application scene. For example, the dynamic resource and the static resource may be used as part of the access address in different paths, so that when the address of the resource requested by the terminal includes the predetermined path of the dynamic resource, it can be known that the page resource request is a request for the dynamic resource; the page resource request is a request for a static resource if a predetermined path for the static resource is included in the resource address. For another example, in an application scenario where a static resource or a dynamic resource is divided according to the extension of the resource, whether the requested dynamic resource or the static resource is requested can be known according to whether the extension of the requested resource is a predetermined extension of the static resource or a predetermined extension of the dynamic resource.
It should be noted that, in this embodiment of the present specification, the CDN node is equivalent to an agent of the terminal, instead of requesting the dynamic resource from the service end by the terminal, so as to accelerate the speed of obtaining the dynamic resource by the terminal by using a more superior network condition between the CDN node and the service end. In an implementation manner, the service end may serve as a source station, and a part of resources (for example, static resources) of the web product is delivered through the CDN system, in this implementation manner, the interaction between the CDN node and the service end includes two parts, one part is a function of synchronizing the CDN node of the CDN system itself with the source station to deliver the resources, the other part is a function of requesting the service end for dynamic resources by the CDN node proxy terminal, and the latter part is not a function of the CDN system itself.
In order to guarantee the transmission speed between the CDN node and the service end from the network infrastructure level, a dedicated line may be used for transmission between the CDN node and the service end, and the transmission bandwidth of the dedicated line may be adjusted according to the transmitted data traffic, so that the requirement of the response speed can still be met when the traffic increases.
On the CDN node, step 130, a page resource response including the dynamic resource is returned to the terminal, so that the terminal performs web page display.
On the terminal, step 220, a page resource response returned by the CDN node server is received, where the page resource response includes dynamic resources acquired by the CDN node from the service server according to the page resource request.
On the terminal, step 230, the web page is rendered using the dynamic resource.
After receiving the dynamic resources sent by the service server, the CDN node returns a page resource response to the terminal, where the page resource response includes the dynamic resources of the terminal provided by the service server. And the terminal displays the web page according to the dynamic resources in the page resource response. For a specific method for displaying a web page by a terminal, please refer to the prior art, which is not described in detail.
In embodiments of the present description, the static resources of the web product may be delivered by the CDN system in a cached or mirrored manner. By means of an operation mechanism of the CDN system, the CDN node locally stores the static resources of the web product (in a mirror image manner, the static resources are pushed to the CDN node for storage, and in a cache manner, the static resources are obtained from a source site of the static resources and then cached to the local). When the page resource request of the terminal is a request for a static resource, the CDN node may issue the static resource in a page resource response to the terminal according to an operation mechanism of the CDN system.
In one implementation, the static resource may be stored locally on the terminal by the browser, the version information of the stored static resource is maintained locally, and whether the static resource for the current web page is updated is compared by the version information, so as to reduce the amount of data that needs to be transmitted between the terminal and the CDN node.
Specifically, when the page resource request of the terminal is a request for a static resource, the terminal carries version information of the static resource stored on the terminal in the page resource request (specific version information may be used to represent a situation that the terminal has not stored the requested static resource yet). After determining that the page resource request is a request for a static resource according to a preset resource type rule, the CDN node extracts version information in the page resource request and compares the version information with locally stored version information of the static resource, and if the version information of the static resource stored by the CDN node is consistent with the version information stored by the terminal, the CDN node returns a notification of the consistent version to the terminal in a page resource response; if the two version information are not consistent, the CDN node returns the update information of the static resource and the version information of the updated static resource (i.e., the version information of the static resource stored on the CDN node) to the terminal in the page resource response. After the terminal receives a page request response returned by the CDN node, if the page resource response comprises a notification of consistent version, the terminal displays a web page by adopting the locally stored static resource; if the page resource response comprises the updating information of the static resource and the updated version information, the terminal upgrades the locally stored static resource according to the updating information, modifies the version information of the static resource into the version information in the page resource response, and displays the web page by the upgraded static resource.
In the implementation manner, the static resource update information sent by the CDN node to the terminal may be a new version of the static resource itself, or may be incremental data of the static resource stored by the CDN node relative to the static resource stored by the terminal. The latter mode can further reduce the data volume needing to be transmitted between the terminal and the CDN node, and improve the speed of web access.
Therefore, in the embodiment of the present specification, the terminal sends the request for the dynamic resource to the CDN node, and the CDN node obtains the dynamic resource from the service end and sends the dynamic resource to the terminal according to the request of the terminal, so that not only can fast transmission between the CDN node and the terminal be utilized, but also fast transmission between the CDN node and the service end can be utilized, thereby greatly accelerating the speed of the terminal in performing a service process through web access.
In one application example of the present specification, the third party payment platform's access portal for web products for payment services employs a single domain name. Therefore, the terminal only needs one DNS query at most when using the web product (when the browser does not have DNS cache of the domain name), the DNS query consumption of the terminal can be reduced to the greatest extent, and the extra time overhead is avoided.
The page resources of each page in the web product are divided into static resources and dynamic resources according to the extension names of the resources. The static resources comprise pictures, fonts, CSS, JS and the like and all have determined static resource extension names; dynamic resources include servlets (a server-side program for interactively browsing and modifying data) with an extension of ". json", an extension of ". do", and the like, each having a certain dynamic resource extension.
The static resources needed in the web product are distributed by the CDN system in a mirror image mode, each CDN node is backed up by the static resources, and version information of the backed up static resources is maintained. The only domain name of the web product is taken over by a CDN system, and when the terminal uses the web product, a page resource request initiated by the domain name is sent to a CDN node closest to the terminal. When the terminal requests the static resource, the interaction among the terminal, the CDN node, and the service server is as shown in fig. 3; when the terminal requests the dynamic resource, the interaction between the terminal, the CDN node, and the service server is as shown in fig. 4.
When a user uses the web product on a terminal, the terminal initiates a page resource request to the CDN node aiming at each page resource on a target web page operated by the user. If the page resource of the web page includes both static resource and dynamic resource, the terminal sends a plurality of page resource requests to the CDN node, where the page resource requests include both a request for the static resource and a request for the dynamic resource.
When a terminal initiates a page resource request to a CDN node, if a requested resource is a static resource, the page resource request carries a version number (version information) of the static resource locally cached by the terminal. And if the cache of the static resource does not exist locally, setting the version number to be 0.
After receiving a page resource request sent by a terminal, a CDN node determines whether the page resource request is a request for dynamic resources or a request for static resources according to whether an extension in a request address pathname is an extension of a predetermined dynamic resource.
If the page resource request is a request for a static resource, the CDN node extracts the version number of the static resource stored by the terminal from the page resource request and compares the version number of the static resource locally stored by the CDN node. If the two version numbers are the same, the CDN node returns a page resource response to the terminal, wherein the page resource response only carries a mark (a notification mode) with the same version number. If the version numbers are different, the CDN node encapsulates the locally stored static resource version, the incremental data of the static resource version stored by the terminal and the version number of the local static resource in a page resource response and sends the page resource response to the terminal. The generation of the incremental data and the upgrading of the locally stored static resources by the terminal by the incremental data are both realized by a reach (a Java script library) Diff (an algorithm for file comparison) mechanism. After the terminal receives the page resource response, if the page resource response carries the mark with the consistent version number, the terminal displays the web page according to the locally stored static resource; and if the page resource response carries incremental data, the terminal updates the locally stored static resources to be consistent with the static resources stored by the CDN node by adopting a Diff algorithm, and updates the local version number. And the terminal displays the web page according to the updated locally stored static resource.
If the request is for the dynamic resource, the CDN node obtains the dynamic resource requested by the terminal from a service server (a service server running the third-party payment platform) of the third-party payment platform, and after obtaining the dynamic resource returned by the service server, encapsulates the dynamic resource in a page resource response, and sends the page resource response to the terminal. And the CDN node and the service server transmit information by a special line with the bandwidth capable of changing along with the communication flow. And after receiving the page resource response, the terminal displays the web page according to the dynamic resources in the page resource response.
Corresponding to the above flow implementation, embodiments of the present specification further provide an implementation apparatus for web access applied to a CDN node, and an implementation apparatus for web access applied to a terminal. Both of these means can be implemented by software, or by hardware, or by a combination of hardware and software. Taking a software implementation as an example, the logical device is formed by reading a corresponding computer program instruction into a memory for running through a Central Processing Unit (CPU) of a device where a terminal or a CDN node is located. In terms of hardware, in addition to the CPU, the memory, and the nonvolatile memory shown in fig. 5, a terminal where the web access implementation apparatus is located or a device where the CDN node is located generally includes other hardware such as a chip for performing wireless signal transmission and reception and/or other hardware such as a board for implementing a network communication function.
Fig. 6 shows an implementation apparatus for web access provided in this specification, which is applied to a CDN node and includes a page resource request receiving unit, a dynamic resource obtaining unit, and a dynamic resource issuing unit, where: the page resource request receiving unit is used for receiving a page resource request sent by the terminal; the dynamic resource obtaining unit is used for obtaining the dynamic resource requested by the terminal from the service server after determining that the page resource request is a request for the dynamic resource according to a preset resource type rule; and the dynamic resource issuing unit is used for returning a page resource response comprising the dynamic resource to the terminal for the terminal to display the web page.
In one implementation, when the page resource request is a request for a static resource, the page resource request further includes: the version information of the static resource stored by the terminal; the device also comprises a static resource issuing unit, which is used for returning a notification of consistent version to the terminal in the page resource response when the version information of the locally stored static resource is consistent with the version information stored in the terminal after the page resource request is determined to be the request of the static resource according to the preset resource type rule; and otherwise, returning the updating information of the static resource and the version information of the updated static resource to the terminal in the page resource response for the terminal to upgrade the static resource and the version information thereof stored by the terminal.
In the foregoing implementation manner, the update information includes: incremental data of the locally stored static resource relative to the static resource stored by the terminal.
Optionally, the predetermined resource type rule includes: the address of the requested resource includes a predetermined path or the requested resource has a predetermined extension.
Optionally, the web access is initiated when the terminal uses a web product, and the web product uses the same domain name.
Optionally, dedicated line transmission is adopted between the CDN node and the service server, and the transmission bandwidth is adjusted according to the transmitted data traffic.
Fig. 7 is a diagram illustrating an apparatus for implementing web access, which is applied to a terminal and includes a dynamic resource request unit, a dynamic resource receiving unit, and a dynamic resource presenting unit, where: the dynamic resource request unit is used for sending a page resource request to a Content Delivery Network (CDN) node, wherein the page resource request is a request for dynamic resources; the dynamic resource receiving unit is used for receiving a page resource response returned by the CDN node, wherein the page resource response comprises dynamic resources acquired by the CDN node from a service server according to the page resource request; the dynamic resource showing unit is used for showing the web page by adopting the dynamic resource.
In one implementation manner, the apparatus further includes a static resource request unit, a static resource receiving unit, and a static resource presenting unit, where: the system comprises a static resource request unit, a CDN node and a resource allocation unit, wherein the static resource request unit is used for sending a page resource request to the CDN node, the page resource request is a request for static resources, and the page resource request comprises locally stored version information of the static resources; the static resource receiving unit is used for receiving a page resource response returned by the CDN node, wherein the page resource response comprises a notification of consistent version, or update information of the static resource and version information of the updated static resource; the static resource display unit is used for displaying the web page by adopting the locally stored static resource when the page resource response comprises a notification of consistent version; and when the page resource response comprises the updating information of the static resource, upgrading the locally stored static resource according to the updating information, updating the version information of the static resource, and displaying the web page by adopting the upgraded static resource.
In the foregoing implementation manner, the update information includes: and incremental data of the static resources stored by the CDN node relative to the static resources stored by the terminal.
Optionally, the address of the dynamic resource includes a predetermined path, or the dynamic resource has a predetermined extension.
Embodiments of the present description provide a CDN node that includes a memory and a processor. Wherein the memory has stored thereon a computer program executable by the processor; the processor, when running the stored computer program, performs the steps of the method for implementing web access applied to the CDN node in the embodiments of the present description. For a detailed description of each step of the implementation method of web access applied to the CDN node, please refer to the previous contents, which are not repeated.
Embodiments of the present description provide a terminal that includes a memory and a processor. Wherein the memory has stored thereon a computer program executable by the processor; the processor, when executing the stored computer program, performs the steps of the method for implementing web access applied on the terminal in the embodiments of the present specification. For a detailed description of the individual steps of the implementation method of web access applied on a terminal, reference is made to the preceding contents, which are not repeated.
Embodiments of the present description provide a computer-readable storage medium having stored thereon computer programs which, when executed by a processor, perform the steps of an implementation method for web access applied on a CDN node in embodiments of the present description. For a detailed description of each step of the implementation method of web access applied to the CDN node, please refer to the previous contents, which are not repeated.
Embodiments of the present specification provide a computer-readable storage medium having stored thereon computer programs that, when executed by a processor, perform the steps of an implementation method for web access applied on a terminal in the embodiments of the present specification. For a detailed description of the individual steps of the implementation method of web access applied on a terminal, reference is made to the preceding contents, which are not repeated.
The above description is only exemplary of the present invention and should not be taken as limiting the scope of the present invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, embodiments of the present description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and so forth) having computer-usable program code embodied therein.