Method, device, electronic device and computer-readable medium for displaying pages
By determining the access mode and selecting a static snapshot file in the homepage of the e-commerce website, the problem that the stability of the e-commerce website's homepage is affected by the upstream interface and operational configuration is solved, and fast response and high-reliability page display are achieved.
Patent Information
- Application Number
- CN201910904179.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-09-24
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2039-09-24
AI Technical Summary
The stability of the e-commerce website's homepage is affected by differences in upstream interface development styles and large variability in operator configuration data, leading to an increased risk of program anomalies. The existing disaster recovery solution relies on redis cache, which suffers from insufficient speed and reliability.
When receiving a page access request, determine whether the access mode of the requested page is snapshot mode. If it is snapshot mode, select an appropriate static page from multiple versions of snapshot files and redirect it to the client to avoid relying on the upstream interface. Use Crawl the complete response content at a preset time interval to generate a snapshot file, and save it in the server's local or external cache to ensure that alternative pages are provided when the upstream interface is unavailable.
It improves the page display speed, reduces the dependence on the upstream interface, enhances the page's ability to quickly recover under abnormal circumstances, and ensures the stability and response speed of the page.
Smart Images

Figure CN111767486B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a method, device, electronic device, and computer-readable medium for displaying a page. Background Art
[0002] As the entry point for the shopping process of e-commerce websites, the homepage is an important entry point for e-commerce companies to attract users to make purchases. The stability of homepage access is a key indicator of whether the entire e-commerce website is running reliably. The mobile web page homepage displays rich content, and the data sources include homepage channel operations, flash sales operations, advertising operations, and recommendation algorithms. Due to the large differences in the development styles of the upstream interfaces, the data structures of the data sent by each interface are quite different, which increases the difficulty of the homepage server processing program and the risk of program exceptions. In addition, the data of each floor and activity on the homepage is usually configured by the operator in the management background. The data is highly variable, which increases the test of program stability and increases the risk of program exceptions.
[0003] In order to deal with home page anomalies, the existing technology usually adopts the following disaster recovery solution: when the upstream interface is normal, the interface data is cached in redis (an open source Key-Value cache). When the upstream interface is unavailable, the interface data is obtained from redis, and the interface data is rendered and assembled into a complete page and then returned to the browser. Summary of the invention
[0004] The embodiments of the present application provide a method, an apparatus, an electronic device, and a computer-readable medium for displaying a page.
[0005] In a first aspect, an embodiment of the present application provides a method for displaying pages, which is applied to a server, and the method includes: in response to receiving a page access request, determining whether the access mode of the requested page is a snapshot mode; if the access mode of the requested page is a snapshot mode, determining a snapshot file to be displayed from snapshot files of multiple versions of the requested page, wherein the snapshot file of the requested page is a static page generated by the server based on the complete response content of the requested page captured at a timed interval; and redirecting the page access request to the determined snapshot file.
[0006] In some embodiments, determining whether the access mode of the requested page is the snapshot mode includes: detecting whether the upstream interface of the requested page can return correct data; if the upstream interface cannot return correct data, determining that the access mode of the requested page is the snapshot mode.
[0007] In some embodiments, determining whether the access mode of the requested page is the snapshot mode includes: obtaining configuration information of the requested page; and determining whether the access mode of the requested page is the snapshot mode based on the configuration information.
[0008] In some embodiments, a snapshot file of a requested page is generated by a thread started asynchronously when the server is started through the following steps: capturing the complete response content of the requested page at a preset time interval; detecting whether the complete response content can correctly render the page; if the complete response content can correctly render the page, generating a static page based on the complete response content as a snapshot file of the requested page during the capture time period.
[0009] In some embodiments, the method further includes: saving a snapshot file of the requested page locally on the server.
[0010] In some embodiments, the method further comprises: writing the complete response content to an external cache.
[0011] In some embodiments, determining a snapshot file to be displayed from multiple versions of snapshot files of a requested page includes: determining an expected version of the snapshot file to be displayed based on configuration information of the requested page; if the server stores a snapshot file of the expected version, determining the snapshot file of the expected version as the snapshot file to be displayed.
[0012] In some embodiments, determining a snapshot file to be displayed from snapshot files of multiple versions of a requested page also includes: if the server does not have a snapshot file of the expected version, determining whether the server stores a snapshot file of a previous version of the expected version; if the server stores a snapshot file of a previous version of the expected version, determining the snapshot file of the previous version of the expected version as the snapshot file to be displayed.
[0013] In some embodiments, the method further includes: if there is no snapshot file of the previous version of the expected version, obtaining the complete response content of the requested page from the external cache; rendering the complete response content, and redirecting the page access request to the rendered page.
[0014] In some embodiments, the method further includes: if the complete response content of the requested page is not obtained, obtaining a static backup page of the requested page from an external content distribution network node; and redirecting the page access request to the static backup page.
[0015] In some embodiments, the method further includes: pushing the snapshot file of the requested page to an external distribution network node for storage.
[0016] In a second aspect, an embodiment of the present application provides a device for displaying pages, which is applied to a server, and the device includes: a mode determination unit, configured to determine whether the access mode of the requested page is a snapshot mode in response to receiving a page access request; a snapshot determination unit, configured to determine a snapshot file to be displayed from multiple versions of snapshot files of the requested page if the access mode of the requested page is a snapshot mode, wherein the snapshot file of the requested page is a static page generated by the server based on the complete response content of the requested page captured at a timed interval; and a redirection unit, configured to redirect the page access request to the determined snapshot file.
[0017] In some embodiments, the mode determination unit includes: a data detection module, configured to detect whether the upstream interface of the requested page can return correct data; a mode determination module, configured to determine that the access mode of the requested page is a snapshot mode if the upstream interface cannot return correct data.
[0018] In some embodiments, the mode determination unit includes: a configuration acquisition module configured to acquire configuration information of the requested page; and a mode determination module configured to determine whether the access mode of the requested page is a snapshot mode based on the configuration information.
[0019] In some embodiments, a snapshot file of a requested page is generated by a thread started asynchronously when the server is started through the following steps: capturing the complete response content of the requested page at a preset time interval; detecting whether the complete response content can correctly render the page; if the complete response content can correctly render the page, generating a static page based on the complete response content as a snapshot file of the requested page during the capture time period.
[0020] In some embodiments, the device further includes: a snapshot saving unit configured to save a snapshot file of the requested page locally on the server.
[0021] In some embodiments, the apparatus further comprises: a data writing unit configured to write the complete response content into an external cache.
[0022] In some embodiments, the snapshot determination unit includes: a version determination module, configured to determine the expected version of the snapshot file to be displayed based on the configuration information of the requested page; and a first snapshot determination module, configured to determine the expected version of the snapshot file as the snapshot file to be displayed if the server stores the expected version of the snapshot file.
[0023] In some embodiments, the snapshot determination unit also includes: a file determination module, configured to determine whether the server stores a snapshot file of a previous version of the expected version if the server does not have a snapshot file of the expected version; and a second snapshot determination module, configured to determine the snapshot file of the previous version of the expected version as the snapshot file to be displayed if the server stores a snapshot file of the previous version of the expected version.
[0024] In some embodiments, the device also includes: a data acquisition unit, configured to obtain the complete response content of the requested page from an external cache if a snapshot file of the previous version of the expected version does not exist; a rendering unit, configured to render the complete response content and redirect the page access request to the rendered page.
[0025] In some embodiments, the device also includes: a backup page acquisition unit, configured to acquire a static backup page of the requested page from an external content distribution network node if the complete response content of the requested page is not acquired; wherein the redirection unit is also configured to redirect the page access request to the static backup page.
[0026] In some embodiments, the apparatus further includes: a snapshot pushing unit configured to push the snapshot file of the requested page to an external distribution network node for storage.
[0027] In a third aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors; a storage device on which one or more programs are stored; when the one or more programs are executed by one or more processors, the one or more processors implement the method described in any implementation method in the first aspect.
[0028] In a fourth aspect, an embodiment of the present application provides a computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.
[0029] The method, device, electronic device and computer-readable medium for displaying pages provided in the embodiments of the present application determine the access mode of the requested page when a page access request is received, and determine the snapshot file to be displayed when the access mode of the requested page is a snapshot mode, and finally redirect the page access request to the determined snapshot file and return it to the client, thereby redirecting the page access request to the snapshot file of the requested page without relying on the upstream interface of the requested page, thereby speeding up the display speed of the requested page. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0031] Figure 1 is an exemplary system architecture diagram in which an embodiment of the present application may be applied;
[0032] Figure 2 is a flowchart of an embodiment of a method for displaying a page according to the present application;
[0033] FIG. 3A to FIG. 3D is a schematic diagram of an application scenario of the method for displaying pages according to the present application;
[0034] Figure 4 is a schematic structural diagram of an embodiment of a device for displaying pages according to the present application;
[0035] Figure 5 It is a structural schematic diagram of an electronic device suitable for implementing the embodiments of the present application. DETAILED DESCRIPTION
[0036] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant invention, rather than to limit the invention. It should also be noted that, for ease of description, only the parts related to the relevant invention are shown in the accompanying drawings.
[0037] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0038] Figure 1 An exemplary system architecture 100 is shown to which an embodiment of a method for displaying a page or an apparatus for displaying a page of the present application can be applied.
[0039] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0040] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0041] Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices with display screens and supporting page display, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, etc. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, to provide distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0042] The server 105 may be a server that provides various services, such as a background server that supports client applications on the terminal devices 101, 102, and 103. The server 105 may analyze and process the received data such as page access requests, and return the processing results (such as redirected page snapshot files) to the terminal devices 101, 102, and 103.
[0043] It should be noted that the method for displaying a page provided in the embodiment of the present application is generally executed by the server 105 , and accordingly, the device for displaying a page is generally set in the server 105 .
[0044] It should be noted that the server 105 can be hardware or software. When the server 105 is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules (for example, for providing distributed services), or it can be implemented as a single software or software module. No specific limitation is made here.
[0045] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. According to the implementation requirements, there may be any suitable number of terminal devices, networks and servers.
[0046] Continue to refer Figure 2 , shows a process 200 of an embodiment of a method for displaying a page according to the present application. The method for displaying a page may include the following steps:
[0047] Step 201: In response to receiving a page access request, determine whether the access mode of the requested page is a snapshot mode.
[0048] In this embodiment, the execution body of the method for displaying a page (eg Figure 1 The server 105) can receive the terminal device (for example) through a wired connection or a wireless connection. Figure 1When receiving the page access request, the access mode of the page requested to be accessed by the terminal device (hereinafter referred to as the request page) is determined.
[0049] Here, the requested page can be a page presented by a client application installed on the terminal device (for example, the homepage of shopping application A), or a page presented by a browser installed on the terminal device (for example, the homepage of e-commerce website B).
[0050] Preferably, the request page can be the home page of the client application or the home page of the portal website. The home page of the client application or the home page of the portal website is usually mainly for display, and involves less form-based interaction, so the displayed page will basically not be different due to form interaction. In other words, when the request page is the home page, the method for displaying the page in this embodiment can bring users a better user experience.
[0051] Accordingly, the server may be a server that provides support for the client application (eg, shopping application A), or a server that provides support for a portal website (eg, e-commerce website B).
[0052] It should be pointed out that the above-mentioned wireless connection methods may include but are not limited to 3G (the 3rd generation) / 4G (the 4th generation) / 5G (the 5th generation) communication connection, Wi-Fi (Wireless-Fidelity) connection, Bluetooth connection, WiMAX (Worldwide Interoperability for Microwave Access) connection, Zigbee (also known as Zigbee protocol) connection, UWB (UltraWideband) connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultrawideband) connection, and other wireless connection methods currently known or developed in the future.
[0053] In this embodiment, the access mode of the above-mentioned request page may include a snapshot mode and an upstream interface mode. Specifically, the snapshot mode may refer to an access mode for displaying a snapshot file of the request page, and the upstream interface mode may refer to an access mode for obtaining interface content by calling the upstream interface of the request page and rendering the interface content into a page for display. Here, the upstream interface may be an interface provided by a server that generates content (i.e., an upstream server). Generally speaking, a request page may include multiple display contents, and each display content may correspond to an upstream interface.
[0054] It should be noted that the upstream server and the above-mentioned execution entity can be the same server or different servers, and this application does not make any specific limitations on this.
[0055] In some optional implementations of this embodiment, step 201 may specifically include:
[0056] First, it is detected whether the upstream interface of the request page can return correct data. For example, the execution subject can call the upstream interface of the request page and determine whether the upstream interface can return correct data according to the returned response content.
[0057] Then, if the upstream interface of the above-mentioned request page can return correct data, it can be determined that the access mode of the above-mentioned request page is the upstream interface mode; otherwise, if the upstream interface of the above-mentioned request page cannot return correct data (that is, the upstream interface is unavailable), it can be determined that the access mode of the above-mentioned request page is the snapshot mode.
[0058] In some optional implementations of this embodiment, step 201 may specifically include:
[0059] First, obtain the configuration information of the request page. The configuration information may include information indicating the access mode of the request page. Here, the configuration information of the request page may be the configuration information set online by the operation management personnel. For example, the operation personnel find that the upstream interface of the homepage is unavailable, so they modify the access mode configuration information of the homepage to access the snapshot file.
[0060] Then, the execution subject may determine whether the access mode of the requested page is the snapshot mode according to the configuration information. For example, if the execution subject detects that the operator switches the configuration information of the home page to access the snapshot file, the access mode of the home page may be determined to be the snapshot mode.
[0061] Step 202: If the access mode of the requested page is the snapshot mode, a snapshot file to be displayed is determined from snapshot files of multiple versions of the requested page.
[0062] In this embodiment, if step 201 determines that the access mode of the requested page is the snapshot mode, the execution body of the method for displaying the page (eg Figure 1The server 105) can determine the snapshot file to be displayed to the client from the snapshot files of multiple versions of the above-mentioned request page. Among them, the snapshot file of the above-mentioned request page can be a static page generated by the above-mentioned execution subject based on the complete response content of the above-mentioned request page captured at a fixed time. For example, the above-mentioned execution subject can call each upstream interface of the homepage at the 17th minute of each hour (or other times) to obtain the complete response content to generate a static page as a version of the snapshot file. Here, the version of the snapshot file can be determined by the time period of the captured content. For example, the version of the snapshot file generated by capturing the interface content at 01:17 on July 28, 2018 can be 20180728_01.
[0063] In some optional implementations of this embodiment, a thread dedicated to obtaining the snapshot file can be asynchronously started when the execution subject is started. Corresponding to this implementation, the snapshot file of the requested page can be generated by the thread through the following steps:
[0064] First, the complete response content of the above request page is captured at a preset time interval. Here, the preset time interval can be a time interval of 15 minutes, 1 hour, 2 hours, etc. The above complete response content can include the interface content returned by each upstream interface of the above request page.
[0065] Afterwards, check whether the above complete response content can correctly render the page. Due to the operational characteristics of the request page itself, many floor data displayed to users on the request page (i.e., data displayed layer by layer) are configured by the operator in the background. If the data configured by the operator contains content that is incompatible with the front-end code (for example, escape characters), it will cause the front-end code to report an error when rendering the page (i.e., the page cannot be rendered correctly). Here, being able to render the page correctly can mean that the captured interface content is compatible with the front-end code.
[0066] Finally, if the complete response content can correctly render the page, the thread can generate a static page based on the complete response content as a snapshot file of the requested page during the crawling time period. As an example, the thread can render the complete response content into a static page in HTML format (a common web page format).
[0067] Optionally, the method for displaying a page may further include: saving a snapshot file of the requested page locally on the execution subject.
[0068] Optionally, the method for displaying pages may further include: writing the above complete response content into an external cache (eg, redis).
[0069] In some optional implementations of this embodiment, step 202 may specifically include:
[0070] The first step is to determine the expected version of the snapshot file to be displayed according to the configuration information of the request page. For example, by parsing the online configuration information of the request page, it is determined that the expected version of the snapshot file to be displayed on the request page is 20180728_01.
[0071] In the second step, the execution subject may determine whether the expected version of the snapshot file is stored locally. If the expected version of the snapshot file is stored locally, the expected version of the snapshot file may be determined as the snapshot file to be displayed.
[0072] Although the above implementation describes that the expected version of the snapshot file to be displayed is determined according to the configuration information of the request page, the present application is not limited thereto. Those skilled in the art will appreciate that other appropriate methods may be used to determine the expected version of the snapshot file to be displayed. For example, when the configuration information does not include the version information of the snapshot file, the expected version of the snapshot file to be displayed may be determined by the time period (or the previous time period, etc.) at which the page access request is received.
[0073] In some optional implementations of this embodiment, step 202 may also include:
[0074] In the third step, if the snapshot file of the expected version does not exist locally, it can be determined whether a snapshot file of the previous version (for example, 20180727_24) of the expected version is stored locally.
[0075] In the fourth step, if a snapshot file of a previous version of the expected version is stored locally, the snapshot file of the previous version of the expected version may be determined as the snapshot file to be displayed.
[0076] Step 203: redirect the page access request to the determined snapshot file.
[0077] In this embodiment, the execution body of the method for displaying a page (eg Figure 1 The server 105) can redirect the page access request received in step 201 to the snapshot file determined in step 202, so that the redirected snapshot file can be returned to the client for display.
[0078] In some optional implementations of this embodiment, if neither the snapshot file of the expected version nor the snapshot file of the previous version of the expected version exists locally, it can be considered that the snapshot file of the requested page is not stored locally. In this case, the method for displaying a page may also include:
[0079] If there is no snapshot file of the previous version of the expected version, the complete response content of the requested page can be obtained from an external cache (e.g., redis); then the complete response content is rendered, and the page access request is redirected to the rendered page.
[0080] The above implementation can avoid the problem that the requested page cannot be accessed due to the snapshot file of the requested page not being stored locally.
[0081] In some optional implementations of this embodiment, the method for displaying pages may further include: if the complete response content of the above-mentioned requested page is not obtained (for example, the above-mentioned external cache does not store the complete response content of the above-mentioned requested page), then a static backup page (also referred to as a bottom page) of the above-mentioned requested page can be obtained from an external content distribution network node (abbreviated as CDN); and then the above-mentioned page access request is redirected to the above-mentioned static backup page.
[0082] Compared with the above-mentioned servers or caches, CDN is more stable and reliable. Placing the static backup page of the requested page on CDN can ensure that the requested page can be displayed normally even in extreme situations such as the upstream interface is unavailable and the front-end code is incompatible.
[0083] In some optional implementations of this embodiment, the method for displaying a page may further include: pushing the snapshot file of the requested page to the CDN for storage. In this way, the execution subject can determine the snapshot file to be displayed from the multiple versions of snapshot files stored on the CDN, and redirect the page access request to the determined snapshot file.
[0084] The above implementation method enables users to obtain required content nearby by deploying network nodes in various places, thereby improving the user access response speed.
[0085] Compared with caching the interface data of the upstream interface in redis as an interface-level bottom cache, the method for displaying pages in this embodiment uses a snapshot method that stores the complete page content on the server in a time-dimensioned version-differentiated manner. In snapshot mode, it redirects to the snapshot static page without relying on external resources such as redis, and has a faster speed than high-speed redis. In addition, in the case of unavailable upstream interfaces, operator configuration errors leading to incompatible front-end codes, etc., the page can be quickly (for example, in seconds) restored to normal access, ensuring normal display of the page.
[0086] Continue to refer Figure 3A and Figure 3B , which shows an application scenario of the method for displaying a page according to the present application. In this application scenario, first, as Figure 3AAs shown, the snapshot thread 301 asynchronously started when the server 302 is started calls the upstream interface of the homepage (here, the upstream interface is also provided by the server 302) at the 17th minute of each hour to capture the interface content. Then, when the snapshot thread 301 determines that the complete response data returned by the upstream interface is available, it renders the above complete response data into the homepage snapshot of the time period and stores it locally on the server 302. Next, as Figure 3B and Figure 3C As shown, when the user's finger 304 clicks on the application 305 installed on the smartphone 303, the smartphone 303 sends a homepage access request including "m.jd.com" to the server 302. At this time, the homepage is in snapshot access mode, so the server 302 first hits the expected version 20180728_01 of the homepage snapshot to be displayed locally (that is, there is a local file path " / snapshot / 20180728_01.html"), then redirects the homepage access request to the homepage snapshot and returns it to the smartphone 303. Finally, as Figure 3D As shown, a home page 306 (ie, a home page snapshot) of an application 305 is displayed on a smart phone 303 .
[0087] The method for displaying pages provided by the above-mentioned embodiments of the present application determines the access mode of the requested page when a page access request is received, and determines the snapshot file to be displayed when the access mode of the requested page is a snapshot mode, and finally redirects the page access request to the determined snapshot file and returns it to the client, thereby being able to redirect the page access request to the snapshot file of the requested page without relying on the upstream interface of the requested page, thereby speeding up the display speed of the requested page.
[0088] Further references Figure 4 , as a pair Figure 2 The present application provides an embodiment of a device for displaying a page, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied in a server.
[0089] like Figure 4As shown, the device 400 for displaying a page in this embodiment may include a mode determination unit 401, a snapshot determination unit 402, and a redirection unit 403. The mode determination unit 401 may be configured to determine whether the access mode of the requested page is a snapshot mode in response to receiving a page access request. The snapshot determination unit 402 may be configured to determine the snapshot file to be displayed from the snapshot files of multiple versions of the requested page if the access mode of the requested page is a snapshot mode. The snapshot file of the requested page may be a static page generated by the server based on the complete response content of the requested page captured at a fixed time. The redirection unit 403 may be configured to redirect the page access request to the determined snapshot file.
[0090] In this embodiment, the specific implementation of the mode determination unit 401, the snapshot determination unit 402 and the redirection unit 403 of the apparatus 400 for displaying a page can be referred to in Figure 2 The relevant descriptions about steps 201 to 203 in the corresponding embodiment are not repeated here.
[0091] In some optional implementations of this embodiment, the mode determination unit 401 may include a data detection module and a mode determination module. The data detection module may be configured to detect whether the upstream interface of the requested page can return correct data. The mode determination module may be configured to: if the upstream interface cannot return correct data, determine that the access mode of the requested page is snapshot mode.
[0092] In some optional implementations of this embodiment, the mode determination unit 401 may include a configuration acquisition module and a mode determination module. The configuration acquisition module may be configured to acquire configuration information of the requested page. The mode determination module may be configured to determine whether the access mode of the requested page is the snapshot mode based on the configuration information.
[0093] In some optional implementations of this embodiment, the snapshot file of the above-mentioned requested page can be generated by a thread that is started asynchronously when the server is started through the following steps: capturing the complete response content of the requested page at a preset time interval; detecting whether the complete response content can correctly render the page; if the complete response content can correctly render the page, generating a static page based on the complete response content as a snapshot file of the requested page during the capture time period.
[0094] In some optional implementations of this embodiment, the device 400 may further include a snapshot saving unit, wherein the snapshot saving unit may be configured to save the snapshot file of the requested page locally on the server.
[0095] In some optional implementations of this embodiment, the apparatus 400 may further include a data writing unit, wherein the data writing unit may be configured to write the complete response content into an external high-speed cache.
[0096] In some optional implementations of this embodiment, the snapshot determination unit 402 may include a version determination module and a first snapshot determination module. The version determination module may be configured to determine the expected version of the snapshot file to be displayed according to the configuration information of the request page. The first snapshot determination module may be configured to: if the server stores a snapshot file of the expected version, determine the snapshot file of the expected version as the snapshot file to be displayed.
[0097] In some optional implementations of this embodiment, the snapshot determination unit 402 may further include a file determination module and a second snapshot determination module. The file determination module may be configured to: if the server does not have a snapshot file of the expected version, determine whether the server stores a snapshot file of a previous version of the expected version. The second snapshot determination module may be configured to: if the server stores a snapshot file of a previous version of the expected version, determine the snapshot file of the previous version of the expected version as the snapshot file to be displayed.
[0098] In some optional implementations of this embodiment, the device 400 may further include a data acquisition unit and a rendering unit. The data acquisition unit may be configured to: if there is no snapshot file of the previous version of the expected version, obtain the complete response content of the requested page from the external cache. The rendering unit may be configured to: render the complete response content and redirect the page access request to the rendered page.
[0099] In some optional implementations of this embodiment, the device 400 may further include a standby page acquisition unit. The standby page acquisition unit may be configured to: if the complete response content of the requested page is not obtained, obtain a static standby page of the requested page from an external content distribution network node. The redirection unit 403 may also be configured to redirect the page access request to the static standby page.
[0100] In some optional implementations of this embodiment, the apparatus 400 may further include a snapshot pushing unit, wherein the snapshot pushing unit may be configured to push the snapshot file of the requested page to an external distribution network node for storage.
[0101] The device for displaying pages provided by the above-mentioned embodiments of the present application determines the access mode of the requested page when receiving a page access request, and determines the snapshot file to be displayed when the access mode of the requested page is a snapshot mode, and finally redirects the page access request to the determined snapshot file and returns it to the client, thereby being able to redirect the page access request to the snapshot file of the requested page without relying on the upstream interface of the requested page, thereby speeding up the display speed of the requested page.
[0102] Reference below Figure 5 , which shows an electronic device suitable for implementing the embodiments of the present application (for example, Figure 1 A schematic diagram of the structure of the server 105)500 is shown. Figure 5 The electronic device 500 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0103] like Figure 5 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0104] The following devices may be connected to the I / O interface 505: an input device 506 including, for example, a mouse, a keyboard, a microphone, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, etc.; a storage device 508 including, for example, a memory card, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Figure 5 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead. Figure 5 Each block shown in the figure may represent one device, or may represent multiple devices as required.
[0105] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 509, or installed from a storage device 508, or installed from a ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0106] It should be noted that the computer-readable medium described in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In an embodiment of the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In an embodiment of the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0107] The computer program code for performing the operation of the embodiment of the present application can be written in one or more programming languages or a combination thereof, and the programming language includes an object-oriented programming language, such as Java, Smalltalk, C++, and also includes a conventional procedural programming language, such as "C" language or similar programming language. The program code can be executed completely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer, partially on the remote computer, or completely on the remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer by any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect to the Internet).
[0108] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0109] The units involved in the embodiments described in the present application may be implemented by software or by hardware. The units described may also be set in a processor, for example, it may be described as: a processor includes a mode determination unit, a snapshot determination unit and a redirection unit. The names of these units do not constitute a limitation on the units themselves in some cases, for example, the mode determination unit may also be described as "a unit that determines whether the access mode of the requested page is a snapshot mode in response to receiving a page access request".
[0110] As another aspect, the present application also provides a computer-readable medium, which may be included in the server described in the above embodiment; or it may exist independently without being assembled into the server. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by the server, the server: in response to receiving a page access request, determines whether the access mode of the requested page is a snapshot mode; if the access mode of the requested page is a snapshot mode, determines the snapshot file to be displayed from the snapshot files of multiple versions of the requested page, wherein the snapshot file of the requested page is a static page generated by the server based on the complete response content of the requested page captured at a fixed time; redirects the page access request to the determined snapshot file.
[0111] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of the invention involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above invention concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.
Claims
1. A method for displaying a page, applied to a server, the method comprising: In response to receiving a page access request, determining whether the access mode of the requested page is a snapshot mode; wherein the requested page is a home page of a client application or a home page of a portal website; If the access mode of the requested page is snapshot mode, determining a snapshot file to be displayed from snapshot files of multiple versions of the requested page, wherein the snapshot file of the requested page is a static page generated by the server based on the complete response content of the requested page captured at a fixed time; redirecting the page access request to the determined snapshot file; The snapshot file of the requested page is generated by a thread started asynchronously when the server is started through the following steps: Capture the complete response content of the requested page at a preset time interval; Check whether the complete response content is compatible with the front-end code; If the complete response content is compatible with the front-end code, a static page is generated based on the complete response content as a snapshot file of the requested page during the crawling time period.
2. The method according to claim 1, wherein: The step of determining whether the access mode of the requested page is the snapshot mode includes: Detect whether the upstream interface of the requested page can return correct data; If the upstream interface cannot return correct data, it is determined that the access mode of the requested page is a snapshot mode.
3. The method according to claim 1, wherein: The step of determining whether the access mode of the requested page is the snapshot mode includes: Obtaining configuration information of the requested page; Determine whether the access mode of the requested page is a snapshot mode based on the configuration information.
4. The method according to claim 1, wherein: The snapshot file of the requested page is generated by a thread started asynchronously when the server is started through the following steps: Capture the complete response content of the requested page at a preset time interval; Check whether the complete response content can correctly render the page; If the complete response content can correctly render the page, a static page is generated based on the complete response content as a snapshot file of the requested page during the crawling time period.
5. The method according to claim 4, wherein: The method further comprises: The snapshot file of the requested page is saved locally on the server.
6. The method according to claim 4, wherein: The method further comprises: The complete response content is written to the external cache.
7. The method according to claim 1, wherein: The The snapshot file to be displayed is determined from the snapshot files of multiple versions of the requested page, including: Determining the expected version of the snapshot file to be displayed according to the configuration information of the request page; If the server stores the snapshot file of the expected version, the snapshot file of the expected version is determined as the snapshot file to be displayed.
8. The method according to claim 7, wherein: The determining of the snapshot file to be displayed from the snapshot files of the multiple versions of the requested page further includes: If the server does not have the snapshot file of the expected version, determining whether the server stores a snapshot file of a previous version of the expected version; If the server stores a snapshot file of a version previous to the expected version, the snapshot file of the version previous to the expected version is determined as the snapshot file to be displayed.
9. The method according to claim 8, wherein: The method further comprises: If there is no snapshot file of the previous version of the expected version, obtaining the complete response content of the requested page from the external cache; The complete response content is rendered, and the page access request is redirected to the rendered page.
10. The method according to claim 9, wherein: The method further comprises: If the complete response content of the requested page is not obtained, obtaining a static standby page of the requested page from an external content distribution network node; The page access request is redirected to the static standby page.
11. The method according to claim 4, wherein: The method further comprises: The snapshot file of the requested page is pushed to an external distribution network node for storage.
12. A device for displaying a page, applied to a server, the device comprising: A mode determination unit is configured to determine, in response to receiving a page access request, whether the access mode of the requested page is a snapshot mode; wherein the requested page is a home page of a client application or a home page of a portal website; a snapshot determining unit, configured to determine a snapshot file to be displayed from snapshot files of multiple versions of the requested page if the access mode of the requested page is the snapshot mode, wherein the snapshot file of the requested page is a static page generated by the server based on the complete response content of the requested page captured at a fixed time; A redirection unit, configured to redirect the page access request to the determined snapshot file; The snapshot file of the requested page is generated by a thread started asynchronously when the server is started through the following steps: Capture the complete response content of the requested page at a preset time interval; Check whether the complete response content is compatible with the front-end code; If the complete response content is compatible with the front-end code, a static page is generated based on the complete response content as a snapshot file of the requested page during the crawling time period.
13. An electronic device comprising: one or more processors; a storage device having one or more programs stored thereon, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 11.
14. A computer readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.
