Page Loading Method, Device, Storage Medium, and Electronic Device
By leveraging temporary and persistent cache databases alongside server intermediate layers, the method addresses server overload and instability during high page request volumes, ensuring efficient and stable page loading.
Patent Information
- Application Number
- CN202110166066.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-02-03
- Publication Date
- 2025-07-15
- Estimated Expiration
- 2041-02-03
AI Technical Summary
When the instantaneous page request volume is large, the server side is under pressure and the stability is poor. The existing technology cannot generate page rendering files in a timely manner, resulting in poor service stability of page rendering files.
By obtaining page rendering files from multiple file sources of temporary cache database, server middle layer and resident cache database, combined with client rendering instructions for single-page network applications, the page loading process is optimized and server pressure and memory usage is reduced.
Improves the service stability and response speed of page loading, reduces server pressure, reduces memory space usage, and ensures the integrity and timely response of page rendering files.
Smart Images

Figure CN113569173B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technologies, and in particular, to a page loading method, a page loading device, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the rapid development of Internet technologies, as a display method of media information, front-end pages are increasingly popular and attracting more attention.
[0003] Currently, in the related art, when a client requests a page, the server generates a page rendering file through an offline service and returns it to the client for page loading. However, in this technical solution, when the instantaneous page request volume is large, the page rendering file cannot be generated in time through the offline service, resulting in a large pressure on the server. At the same time, when there is a problem with the offline service on the server, it may lead to the inability to respond to the page request to generate the page rendering file, resulting in poor service stability of the page rendering file.
[0004] It should be noted that the information disclosed in the above background art section is only used to enhance the understanding of the background of the present disclosure, and thus may include information that does not constitute the prior art known to those of ordinary skill in the art. Summary of the Invention
[0005] The purpose of the present disclosure is to provide a page loading method, a page loading device, an electronic device, and a computer-readable storage medium, so as to overcome, to a certain extent, the problems of large server pressure and poor stability when the request volume of the target page in the front end is large, which are caused by the limitations and defects of the related art.
[0006] According to a first aspect of the present disclosure, there is provided a page loading method, including:
[0007] Responding to a request from a client to load a target page, determining a target file source that provides a page rendering file corresponding to the target page from a preset file source, where the file source includes a temporary cache database, a server middle layer, and a resident cache database;
[0008] Obtaining the page rendering file from the target file source and returning the page rendering file to the client, so that the client loads and generates the target page according to the page rendering file.
[0009] In an exemplary embodiment of the present disclosure, based on the foregoing solution, the method further includes:
[0010] If none of the preset file sources can provide the page rendering file corresponding to the target page, a client rendering instruction is returned to the client, so that the client loads and generates the target page in the form of a single-page web application.
[0011] In an exemplary embodiment of the present disclosure, based on the foregoing solution, determining a target file source that provides the page rendering file corresponding to the target page from the preset file sources includes:
[0012] Detecting whether the temporary cache database storing the page rendering file has been constructed;
[0013] If it is detected that the temporary cache database storing the page rendering file has been constructed, the temporary cache database is used as the target file source;
[0014] If it is detected that the temporary cache database storing the page rendering file has not been constructed, the server middle layer is used as the target file source, and the page rendering file is generated through the server middle layer.
[0015] In an exemplary embodiment of the present disclosure, based on the foregoing solution, the generating the page rendering file through the server middle layer further includes:
[0016] Obtaining a preset time threshold, and detecting whether the time used by the server middle layer to generate the page rendering file is greater than or equal to the time threshold;
[0017] If it is detected that the time used by the server middle layer to generate the page rendering file is greater than or equal to the preset time threshold, the resident cache database is used as the target file source.
[0018] In an exemplary embodiment of the present disclosure, based on the foregoing solution, the generating the page rendering file through the server middle layer includes:
[0019] Generating the page rendering file by the server middle layer calling a backend interface; and
[0020] When it is detected that the backend interface cannot provide services, obtaining a pre-set static resource file based on the server middle layer, and generating the page rendering file according to the static resource file.
[0021] In an exemplary embodiment of the present disclosure, based on the foregoing solution, if the temporary cache database storing the page rendering file has not been generated, using the server middle layer as the target file source, and generating the page rendering file through the server middle layer further includes:
[0022] Return the page rendering file generated by the server middle layer to the client; and
[0023] According to the page rendering file generated by the server middle layer, construct a temporary cache database storing the page rendering file, and update the historical page rendering file stored in the resident cache database.
[0024] In an exemplary embodiment of the present disclosure, based on the foregoing solution, the method further includes:
[0025] Receive a control instruction sent by the management terminal;
[0026] Trigger a preset offline automation script through the control instruction to update the temporary cache database, the resident cache database, and the static resource file for generating the page rendering file.
[0027] According to a second aspect of the present disclosure, there is provided a page loading device, including:
[0028] A file source determination module, configured to, in response to a request from a client to load a target page, determine a target file source that provides a page rendering file corresponding to the target page from a preset file source, where the file source includes a temporary cache database, a server middle layer, and a resident cache database;
[0029] A target page loading module, configured to obtain the page rendering file from the target file source and return the page rendering file to the client, so that the client loads and generates the target page according to the page rendering file.
[0030] According to a third aspect of the present disclosure, there is provided an electronic device, including: a processor; and a memory for storing executable instructions of the processor; wherein, the processor is configured to execute the method according to any one of the above by executing the executable instructions.
[0031] According to a fourth aspect of the present disclosure, there is provided a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the method according to any one of the above is implemented.
[0032] The exemplary embodiments of the present disclosure may have some or all of the following beneficial effects:
[0033] In the page loading method provided by an exemplary embodiment of the present disclosure, in response to a request from a client to load a target page, a target file source for providing a page rendering file corresponding to the target page is determined from a preset file source. The file source includes a temporary cache database, a server middle layer, and a resident cache database. The page rendering file is obtained from the target file source and returned to the client, so that the client can load and generate the target page according to the page rendering file. On the one hand, by providing multiple file sources to obtain the page rendering file corresponding to the target page, it is possible to effectively handle the situation where the instantaneous page request volume is relatively large, improve the service stability and response speed of the target page. Specifically, by obtaining the page rendering file from the temporary cache database, the service pressure on the server middle layer to generate the page rendering file can be effectively reduced. By obtaining the page rendering file from the resident cache database, the integrity of the page rendering file can be ensured. In the case of a large instantaneous page request volume, through the cooperation among the temporary cache database, the server middle layer, and the resident cache database, the service stability and response speed of the target page can be improved. On the other hand, by determining the target file source to obtain the page rendering file, compared with the related technology of generating the page rendering file by offline service, it is not necessary to regenerate all page rendering files during each version iteration, reducing the generation of files that are not actually used. For the case where the number of page rendering files is relatively large, it can effectively reduce the pressure on the server side and reduce the occupancy of memory space.
[0034] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure. Obviously, the accompanying drawings in the following description are only some embodiments of the present disclosure. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0036] Figure 1 A schematic diagram showing an exemplary system architecture of a page loading method and device to which the embodiments of the present disclosure can be applied;
[0037] Figure 2 A schematic diagram showing the structure of a computer system of an electronic device suitable for implementing the embodiments of the present disclosure;
[0038] Figure 3 A schematic flow chart showing the process of loading a page in the related technology according to an embodiment of the present disclosure;
[0039] Figure 4A flowchart of a page loading method according to an embodiment of the present disclosure is schematically shown;
[0040] Figure 5 A flowchart of determining a source of a target file according to an embodiment of the present disclosure is schematically shown;
[0041] Figure 6 A flowchart of determining a source of a target file according to another embodiment of the present disclosure is schematically shown;
[0042] Figure 7 A flowchart of forcibly updating data according to an embodiment of the present disclosure is schematically shown;
[0043] Figure 8 A flowchart of loading and generating a target page according to an embodiment of the present disclosure is schematically shown;
[0044] Figure 9 A schematic block diagram of a page loading device according to an embodiment of the present disclosure is schematically shown. Detailed implementation manners
[0045] Example embodiments will now be described more fully with reference to the accompanying drawings. However, the example embodiments can be implemented in various forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be more thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art. The features, structures, or characteristics described may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of the embodiments of the present disclosure. However, those skilled in the art will realize that the technical solutions of the present disclosure can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be used. In other cases, well-known technical solutions are not shown or described in detail to avoid obscuring the various aspects of the present disclosure.
[0046] In addition, the drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and thus repeated descriptions thereof will be omitted. Some of the block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0047] Figure 1A schematic diagram of a system architecture of an exemplary application environment to which a page loading method and apparatus according to embodiments of the present disclosure can be applied is shown.
[0048] As Figure 1 shown, the system architecture 100 may include one or more of terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link 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 fiber optic cables, etc. The terminal devices 101, 102, 103 may be various electronic devices with a display screen, including but not limited to desktop computers, portable computers, smart phones, and tablet computers, etc. It should be understood that Figure 1 the numbers of terminal devices, networks, and servers in
[0049] are merely illustrative. According to actual needs, there may be any number of terminal devices, networks, and servers. For example, the server 105 may be a server cluster composed of multiple servers, etc.
[0050] Figure 2 A schematic diagram of a computer system of an electronic device suitable for implementing embodiments of the present disclosure is shown.
[0051] It should be noted that Figure 2 the computer system 200 of the electronic device shown is only an example and should not impose any limitations on the functions and usage scopes of the embodiments of the present disclosure.
[0052] As Figure 2 shown, the computer system 200 includes a central processing unit (CPU) 201, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 202 or programs loaded from a storage section 208 into a random access memory (RAM) 203. In the RAM 203, various programs and data required for system operations are also stored. The CPU 201, ROM 202, and RAM 203 are connected to each other through a bus 204. An input / output (I / O) interface 205 is also connected to the bus 204.
[0053] The following components are connected to the I / O interface 205: an input section 206 including a keyboard, a mouse, etc.; an output section 207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 208 including a hard disk, etc.; and a communication section 209 including a network interface card such as a LAN card, a modem, etc. The communication section 209 performs communication processing via a network such as the Internet. A drive 210 is also connected to the I / O interface 205 as required. A removable medium 211 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is installed on the drive 210 as required so that a computer program read therefrom is installed into the storage section 208 as required.
[0054] Specifically, according to an embodiment of the present disclosure, the processes described below with reference to the flowcharts can be implemented as computer software programs. For example, an embodiment of the present disclosure includes a computer program product that includes a computer program carried on a computer-readable medium, the computer program including program code for performing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 209, and / or installed from the removable medium 211. When the computer program is executed by a central processing unit (CPU) 201, various functions defined in the method and apparatus of the present application are executed.
[0055] It should be noted that the computer-readable medium shown in this disclosure can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of a computer-readable storage medium can 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 this disclosure, a computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, and this computer-readable medium can send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0056] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram can represent a module, a program segment, or a part of code, and the above module, program segment, or part of code contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks can occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks shown can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and the combination of blocks in a block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0057] The units involved in the embodiments of the present disclosure can be implemented in software or in hardware, and the described units can also be provided in a processor. Among them, the names of these units do not constitute a limitation to the unit itself in some cases.
[0058] As another aspect, the present application also provides a computer-readable medium, which can be included in the electronic device described in the above embodiments; or can exist alone without being assembled into the electronic device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by an electronic device, the electronic device implements the methods described in the following embodiments. For example, the electronic device can implement the Figures 4 to 8 various steps shown, etc.
[0059] The technical solutions of the embodiments of the present disclosure are elaborated in detail below:
[0060] In the related technical solutions for generating a front-end page, mainly through a preset automated script, a page rendering file is generated offline. The specific process is as Figure 3 shown. Referring to Figure 3 shown, in step S310, an HTML file is obtained based on the automated script according to the data updated by version iteration, and then a page rendering file is generated based on the HTML file; in step S320, when a front-end page request of the client arrives at the front-end server, it is detected whether the front-end server has generated a page rendering file corresponding to the requested front-end page. If there is a page rendering file generated by the offline service, the page rendering file corresponding to the front-end page is returned to the client. If there is no page rendering file generated by the offline service, step S330 is executed; in step S330, a client rendering instruction is returned to the client. When the client receives the client rendering instruction, the front-end page is loaded and generated in the form of a single-page web application.
[0061] In this solution, in order to keep the data updated, the automated script generates a page rendering file according to each version iteration update. That is, every time the version changes, all page rendering files need to be regenerated. When the number of page rendering files is relatively large, it takes a long time, and many files that are not actually accessed will also be generated, resulting in waste of resources. At the same time, when the request volume of the instantaneous front-end page is relatively large, this technical solution cannot respond to all page requests in time, resulting in low efficiency of front-end page loading and generation. Even in the case of high server pressure, the page service may crash and be unable to respond, and the service stability is poor.
[0062] Based on the above one or more problems, the present exemplary embodiment provides a page loading method. This page loading method can be applied to the above-mentioned server 105. Of course, it can also be applied to one or more of the above-mentioned terminal devices 101, 102, and 103. No special limitation is made in this exemplary embodiment. Refer to Figure 4 As shown, this page loading method may include the following steps S410 to S420:
[0063] Step S410, in response to a request from the client to load a target page, determine a target file source that provides the page rendering file corresponding to the target page from a preset file source, where the file source includes a temporary cache database, a server middle layer, and a resident cache database.
[0064] Step S420, obtain the page rendering file from the target file source and return the page rendering file to the client, so that the client can load and generate the target page according to the page rendering file.
[0065] In the page loading method provided by the present exemplary embodiment, on the one hand, by providing multiple file sources to obtain the page rendering file corresponding to the target page, it can effectively handle the situation where the instantaneous page request volume is large, improve the service stability and response speed of the target page. Specifically, by obtaining the page rendering file from the temporary cache database, it can effectively reduce the service pressure on the server middle layer to generate the page rendering file. By obtaining the page rendering file from the resident cache database, it can ensure the integrity of the page rendering file. When there is a large instantaneous page request volume, through the cooperation between the temporary cache database, the server middle layer, and the resident cache database, the service stability and response speed of the target page are improved; on the other hand, by determining the target file source to obtain the page rendering file, compared with the related art of generating page rendering files through offline services, it is not necessary to regenerate all page rendering files during each version iteration, reducing the generation of files that are not actually used. For the situation where the number of page rendering files is large, it can effectively reduce the pressure on the server side and reduce the occupancy of memory space.
[0066] Next, the above steps of the present exemplary embodiment will be described in more detail.
[0067] In step S410, in response to a request from the client to load a target page, determine a target file source that provides the page rendering file corresponding to the target page from a preset file source, where the file source includes a temporary cache database, a server middle layer, and a resident cache database.
[0068] In an exemplary embodiment of the present disclosure, the target page refers to the front-end page requested by the client for display. The front-end page is the page displayed in the front part of the website, which is a web page presented to the user for browsing on a browser of the corresponding terminal device of the client. With the development of Internet technology, the application of HTML5, CSS3, and front-end frameworks enables cross-platform responsive web design to adapt to various screen resolutions and appropriate animation designs.
[0069] The file source can refer to the source for providing the data used to render and generate the target page. For example, in this exemplary embodiment, the file source can be a temporary cache database (such as a Memcache cache with a set lifecycle), a server middle layer (such as a NodeJS middle layer, where NodeJS is a JavaScript runtime environment that enables JavaScript to run on a server-side development platform, and the NodeJS middle layer can make the service more flexible), or a persistent cache database (such as a Memcache cache with a relatively long lifecycle). Of course, the file source can also be other set file-providing methods, and this exemplary embodiment does not make special limitations in this regard.
[0070] The page rendering file can be a file completed by server-side rendering and containing the HTML structure splicing of the target page. For example, the page rendering file can be an SSR (Server-Side Rendering) file. The process of sending the page rendering file to the browser and then binding the state and events to it to become a fully interactive page. Of course, the page rendering file can also be other files generated by server-side rendering and containing the HTML structure of the target page, and this exemplary embodiment does not make special limitations in this regard.
[0071] The temporary cache database can be a cache database with a pre-set lifecycle. For example, the temporary cache database can be a Memcache cache with a 5-minute lifecycle or a Redis cache with a 5-minute lifecycle. Of course, the Memcache cache or Redis cache can also have other pre-set lifecycles, such as 3 minutes or 10 minutes. This exemplary embodiment is not limited thereto. The temporary cache database is mainly used to effectively relieve and reduce the pressure on the server middle layer of the server caused by repeated traffic during instantaneous bursts of a large number of page requests, and improve the response speed of page requests. According to statistical data, the temporary cache database can serve approximately 46% of the traffic.
[0072] The resident cache database is relative to the temporary cache database. The resident cache database can be a Memcache cache or a Redis cache with a relatively long lifecycle or permanent existence. The resident cache database is mainly used to store continuously updated page rendering files to ensure that at any time, there is a complete page rendering file available for service, as the ultimate fallback guarantee to ensure the stability of page services.
[0073] In step S420, obtain the page rendering file from the target file source and return the page rendering file to the client so that the client can load and generate the target page according to the page rendering file.
[0074] In an exemplary embodiment of the present disclosure, in response to a request from the client to load a target page, determine a target file source that can provide the page rendering file corresponding to the target page from multiple file sources, then obtain the page rendering file from the target file source, and then return the page rendering file to the client, so as to achieve server-side rendering and the client can load and generate the target page, effectively improving the efficiency of generating the target page on the client side and reducing the waiting time of the user.
[0075] Next, steps S410 to S420 will be described in detail.
[0076] In an exemplary embodiment of the present disclosure, if none of the preset file sources can provide the page rendering file corresponding to the target page. For example, in a certain application scenario, when the client requests to load the target page, there is no temporary cache database created and stored with the page rendering file corresponding to the target page in the server, or the temporary cache database has not been updated to store the page rendering file corresponding to the target page, the server middle layer cannot normally call the backend interface or there is a problem with the backend interface, and the resident cache database has not been updated to store the page rendering file corresponding to the target page. At this time, it can be considered that the server cannot provide the file of the page HTML structure, that is, the server-side rendering of the target page cannot be completed. At this time, a client rendering instruction can be returned to the client that requests the target page, so that the client responds to the client rendering instruction and loads and generates the target page in the form of a single-page web application.
[0077] Among them, a single-page web application refers to a form of client-side rendering of the front-end page, that is, a single-page Web application (SPA), which is an application with only one Web page and is a Web application that loads a single HTML page and dynamically updates the page when the user interacts with the application.
[0078] In an exemplary embodiment of the present disclosure, it can be through Figure 5The steps in determine the target file source that provides the page rendering file corresponding to the target page from a preset file source, referring to Figure 5 As shown, it may specifically include:
[0079] Step S510, detect whether the temporary cache database storing the page rendering file has been constructed;
[0080] Step S520, if it is detected that the temporary cache database storing the page rendering file has been constructed, use the temporary cache database as the target file source;
[0081] Step S530, if it is detected that the temporary cache database storing the page rendering file has not been constructed, use the server middle layer as the target file source and generate the page rendering file through the server middle layer.
[0082] Among them, since the life cycle of the temporary cache database is short and it will be automatically revoked after a certain period of time, when a loading request for the target page of the client is detected, first detect whether a temporary cache database storing the page rendering file has been constructed in the server. When the server detects that a temporary cache database storing the page rendering file has been constructed, preferentially use the temporary cache database as the file source that provides the page rendering file corresponding to the target page, that is, the target file source. In this way, when the sudden instantaneous page request volume is large, the page rendering file corresponding to the target page can be directly obtained from the temporary cache database, avoiding the problem that the server middle layer needs to continuously generate page rendering files, resulting in a large service pressure on the server middle layer.
[0083] If it is detected that the server has not constructed a temporary cache database storing the page rendering file, it can be considered that the target page corresponding to this request is the latest and the temporary cache database storing the page rendering file has not been constructed. Therefore, the server middle layer for direct output service can be preferentially used as the target file source, and the page rendering file corresponding to the target page is generated through the server middle layer.
[0084] Specifically, the server middle layer can be used to call the backend interface to generate the page rendering file; among them, the backend interface can be an interface that obtains corresponding data resources according to the request of the target page, and all elements and static data constituting the content of the target page are obtained through the backend interface, and then a page rendering file including the HTML structure corresponding to the target page is generated.
[0085] Further, when it is detected that the backend interface cannot provide services, a preset static resource file can be obtained based on the server middle layer, and a page rendering file can be generated according to the static resource file. The static resource file refers to a static file stored in a Content Delivery Network (CDN), that is, relatively static files (such as pictures, videos, JS scripts, some page frameworks, etc.) in the target page are placed in the CDN. When the backend interface cannot obtain relevant resources of the target page, the static resource file corresponding to the target page is obtained from the CDN network. That is, the static resource file is used as a fallback service for the backend interface. When the backend interface has problems, the static resource file is used as a guarantee for generating the page rendering file, further ensuring the service stability of the server side.
[0086] In an exemplary embodiment of the present disclosure, the target file source providing the page rendering file corresponding to the target page can also be determined from a preset file source through the steps in Figure 6 , as shown in reference to Figure 6 , which may specifically include:
[0087] Step S610, obtain a preset time threshold, and detect whether the time used by the server middle layer to generate the page rendering file is greater than or equal to the time threshold;
[0088] Step S620, if it is detected that the time used by the server middle layer to generate the page rendering file is greater than or equal to the preset time threshold, use the resident cache database as the target file source.
[0089] The time threshold may refer to a preset threshold for determining whether the service of the server middle layer times out. For example, the time threshold can be 1s or 2s. This exemplary embodiment does not make special limitations on this. Furthermore, it can be detected whether the time used by the server middle layer to generate the page rendering file is greater than or equal to the time threshold. If it is detected that the time used by the server middle layer to generate the page rendering file is greater than or equal to the preset time threshold, it can be considered that the service of the server middle layer has timed out. In order to avoid a long loading response time for the target page, at this time, the resident cache database can be used as the target file source for providing the page rendering file corresponding to the target page.
[0090] When neither the temporary cache database nor the server middle layer can be used as the file source for providing the page rendering file corresponding to the target page, the resident cache database that stores the page rendering file preset is used as the target file source for fallback, ensuring the service stability and response speed. At the same time, since the resident cache database always stores and updates the page rendering file, it can ensure the integrity of the page rendering file in various situations.
[0091] In an exemplary embodiment of the present disclosure, when it is determined that a temporary cache database storing a page rendering file has not been generated, the server middle layer is used as the target file source, and after generating the page rendering file through the server middle layer, the page rendering file generated by the server middle layer can be returned to the client. At the same time, based on the page rendering file generated by the server middle layer, a temporary cache database storing the page rendering file can be constructed, and the historical page rendering file stored in the resident cache database can be updated.
[0092] Among them, the historical page rendering file may refer to the historical version of the page rendering file corresponding to the target page generated and stored in a historical page request. By continuously updating the historical page rendering file in the resident cache database, it is ensured that at any time, the resident cache database on the server side can ensure the integrity of the page rendering file.
[0093] Specifically, when constructing a temporary cache database storing a page rendering file, if it is detected that the server has already created a temporary cache database storing other files (such as other page rendering files, resource files, etc.), the temporary cache database is updated with the page rendering file to obtain a temporary cache database storing the page rendering file. Of course, if it is detected that the server has not yet created a temporary cache database, a temporary cache database is created and the page rendering file is stored in the temporary cache database to obtain a temporary cache database storing the page rendering file.
[0094] After the server middle layer generates the page rendering file corresponding to the target page, a short-lived temporary cache database is constructed and the page rendering file is stored. In this way, when the loading request for the target page is repeatedly received subsequently, the page rendering file can be preferentially provided from the temporary cache database, effectively sharing the pressure on the server middle layer in the case of sudden large traffic and improving the response speed of the service. At the same time, the historical page rendering file in the resident cache database is updated according to the newly generated page rendering file to ensure the timeliness of the page rendering file in the resident cache database.
[0095] In an exemplary embodiment of the present disclosure, a management end can also be provided to forcibly intervene in the update of a specified file through the management end to ensure the stability of each file source and service on the server side in the case of sudden large traffic. Refer to Figure 7 As shown, it can specifically include:
[0096] Step S710, receiving a control instruction sent by the management end;
[0097] Step S720: Trigger a preset offline automation script through the control instruction to update the temporary cache database, the resident cache database, and the static resource files for generating the page rendering file.
[0098] Among them, the management terminal can refer to the terminal provided for intervening in the data update of each file source of the server. Through the control instruction sent by the management terminal, a preset offline automation script is triggered to forcibly update the page rendering files stored in the temporary cache database and the resident cache database, as well as the static resource files corresponding to the target page, effectively ensuring the timeliness of the target page and further improving the service stability of the temporary cache database, the resident cache database, and the server middle layer.
[0099] Figure 8 Schematically shows a flowchart of loading and generating a target page according to an embodiment of the present disclosure.
[0100] Reference Figure 8 As shown, in step S801, the request traffic of the user enters the Nginx service for distribution, and responds to the request of the client to load the target page. It is detected whether a temporary cache database storing the page rendering file has been constructed (a Memcache cache with high read and write efficiency for large files can be used. For example, the temporary cache database can be a 5-minute Memcache cache). If it is detected that a temporary cache database storing the page rendering file has been constructed (updated or created), the service is provided, that is, the page rendering file is obtained from the temporary cache database and returned to the requesting client, and the process ends. If it is detected that a temporary cache database storing the page rendering file has not been constructed (not updated or not created), step S802 is executed;
[0101] In step S802, a preset time threshold is obtained, and it is detected whether the server middle layer can respond to the request and whether the time used to generate the page rendering file is greater than or equal to the time threshold. If the server middle layer can respond to the request and the time used to generate the page rendering file is less than the time threshold, step S803 is executed; otherwise, step S807 is executed.
[0102] In step S803, it is detected whether the server middle layer can call the backend interface and whether there is a problem with the backend interface. If the server middle layer can call the backend interface and there is no problem with the backend interface, step S804 is executed; otherwise, S805 is executed.
[0103] Step S804, call the backend interface through the server middle layer to obtain the data resources for constructing the target page, then generate the page rendering file corresponding to the target page based on the obtained data resources, and return the generated page rendering file to the client in an asynchronous communication manner. At the same time, based on the generated page rendering file, construct a temporary cache database for storing the page rendering file, and update the historical page rendering file in the permanent cache database based on the generated page rendering file, and then end the process;
[0104] Step S805, obtain the static resource file corresponding to the target page from the content delivery network based on the server middle layer, then generate the page rendering file according to the static resource file, and based on the generated page rendering file, construct a temporary cache database storing the page rendering file, and update the historical page rendering file in the permanent cache database based on the generated page rendering file;
[0105] Step S806, when it is detected that the data resources corresponding to the target page are updated or files are added, automatically update the temporary cache database, the permanent cache database, and the static resource file (static CDN file) through an offline automation script to ensure the integrity and real-time nature of the data in the temporary cache database and the permanent cache database in an incremental manner;
[0106] Step S807, obtain the control update instruction sent by the management end through the management tool, and trigger the offline automation script according to the control update instruction to forcibly update the specified files that need to be intervened. Through the forced intervention of the management end, avoid the problem that there may be no cached page rendering file or the page rendering file needs to be changed during sudden traffic, and improve the controllability of the service on the server side;
[0107] Step S808, detect whether the permanent cache database can provide the page resource file corresponding to the target page. If the permanent cache database can provide the page resource file corresponding to the target page, then provide the service, that is, obtain the page resource file from the permanent cache database and return the page rendering file to the requesting client and then end the process. Otherwise, execute Step S809;
[0108] Step S809, if none of the preset file sources, namely the temporary cache database, the server middle layer, and the permanent cache database, can provide the page rendering file corresponding to the target page, then return a client rendering instruction to the client to enable the client to load and generate the target page in the form of a single-page web application, and then end the process.
[0109] It should be noted that although the steps of the methods in the present disclosure are described in a specific order in the accompanying drawings, this does not require or imply that these steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution, etc.
[0110] Furthermore, in this exemplary embodiment, a page loading device is also provided. This page loading device can be applied to a server or a terminal device. Referring Figure 9 As shown, the page loading device 900 may include a file source determination module 910 and a target page loading module 920. Among them:
[0111] The file source determination module 910 is configured to, in response to a request from a client to load a target page, determine a target file source that provides a page rendering file corresponding to the target page from a preset file source, where the file source includes a temporary cache database, a server middle layer, and a resident cache database;
[0112] The target page loading module 920 is configured to obtain the page rendering file from the target file source and return the page rendering file to the client, so that the client can load and generate the target page according to the page rendering file.
[0113] In an exemplary embodiment of the present disclosure, the page loading device 900 further includes a client rendering unit, and the client rendering unit can be used for:
[0114] If none of the preset file sources can provide the page rendering file corresponding to the target page, then return a client rendering instruction to the client, so that the client can load and generate the target page in the form of a single-page web application.
[0115] In an exemplary embodiment of the present disclosure, the file source determination module 910 further includes:
[0116] A file source detection unit, configured to detect whether the temporary cache database storing the page rendering file has been constructed;
[0117] A first file source determination unit, configured to, if it is detected that the temporary cache database storing the page rendering file has been constructed, use the temporary cache database as the target file source;
[0118] A second file source determination unit, configured to use the server middle layer as the target file source if it is detected that the temporary cache database storing the page rendering file has not been built, and generate the page rendering file through the server middle layer.
[0119] In an exemplary embodiment of the present disclosure, the second file source determination unit may further be configured to:
[0120] Obtain a preset time threshold, and detect whether the time used by the server middle layer to generate the page rendering file is greater than or equal to the time threshold;
[0121] If it is detected that the time used by the server middle layer to generate the page rendering file is greater than or equal to the preset time threshold, use the resident cache database as the target file source.
[0122] In an exemplary embodiment of the present disclosure, the second file source determination unit may further be configured to:
[0123] Generate the page rendering file by invoking a backend interface through the server middle layer; and
[0124] When it is detected that the backend interface cannot provide services, obtain a preset static resource file based on the server middle layer, and generate the page rendering file according to the static resource file.
[0125] In an exemplary embodiment of the present disclosure, the second file source determination unit further includes a data update subunit, and the data update subunit may be configured to:
[0126] Return the page rendering file generated by the server middle layer to the client; and
[0127] Build the temporary cache database storing the page rendering file according to the page rendering file generated by the server middle layer, and update the historical page rendering files stored in the resident cache database.
[0128] In an exemplary embodiment of the present disclosure, the page loading device 900 further includes a control update unit, and the control update unit may be configured to:
[0129] Receive a control instruction sent by the management end;
[0130] Trigger a preset offline automation script through the control instruction to update the temporary cache database, the resident cache database, and the static resource file for generating the page rendering file.
[0131] The specific details of each module or unit in the above page loading device have been described in detail in the corresponding page loading method, so they will not be elaborated here.
[0132] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more of the above-described modules or units can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0133] Those skilled in the art will readily conceive of other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include known common general knowledge or conventional technical means in the technical field not disclosed herein. The specification and examples are only to be considered as exemplary, and the true scope and spirit of the present disclosure are pointed out by the following claims.
[0134] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.
Claims
1. A page loading method, characterized in that, including: Upon receiving a request from the client to load the target page, detect whether a temporary cache database storing the page rendering file has been constructed; The temporary cache database is a cache database with a preset lifecycle; If it is detected that the temporary cache database storing the page rendering file has been constructed, use the temporary cache database as the target file source; If it is detected that the temporary cache database storing the page rendering file has not been constructed, use the server middle layer as the target file source, and call the backend interface through the server middle layer to generate the page rendering file; And when it is detected that the backend interface cannot provide services, obtain the pre-set static resource file based on the server middle layer, and generate the page rendering file according to the static resource file; Obtain a preset time threshold, and detect whether the time used by the server middle layer to generate the page rendering file is greater than or equal to the time threshold; If it is detected that the time used by the server middle layer to generate the page rendering file is greater than or equal to the preset time threshold, use the permanent cache database as the target file source; the lifecycle of the permanent cache database is longer than that of the temporary cache database; Obtain the page rendering file from the target file source, and return the page rendering file to the client, so that the client can load and generate the target page according to the page rendering file.
2. The page loading method according to claim 1, wherein The method further includes: If none of the preset file sources can provide the page rendering file corresponding to the target page, return a client rendering instruction to the client, so that the client can load and generate the target page in the form of a single-page web application.
3. The page loading method according to claim 1, wherein If the temporary cache database storing the page rendering file has not been generated, use the server middle layer as the target file source, and generate the page rendering file through the server middle layer, further including: Return the page rendering file generated by the server middle layer to the client; and According to the page rendering file generated by the server middle layer, construct the temporary cache database storing the page rendering file, and update the historical page rendering files stored in the permanent cache database.
4. The page loading method according to any one of claims 1 to 3, characterized in that The method further includes: Receive a control instruction sent by the management end; Trigger a preset offline automation script through the control instruction to update the temporary cache database, the permanent cache database, and the static resource file used to generate the page rendering file.
5. A page loading device, characterized in that, including: A file source determination module, configured to, upon receiving a request from the client to load the target page, detect whether a temporary cache database storing the page rendering file has been constructed; The temporary cache database is a cache database with a preset lifecycle; If it is detected that the temporary cache database storing the page rendering file has been constructed, use the temporary cache database as the target file source; If it is detected that the temporary cache database storing the page rendering file has not been built, the server middle layer is used as the source of the target file, and the page rendering file is generated by calling the backend interface through the server middle layer; and when it is detected that the backend interface cannot provide services, obtain the preset static resource file based on the server middle layer, and generate the page rendering file according to the static resource file; Obtain a preset time threshold, and detect whether the time used by the server middle layer to generate the page rendering file is greater than or equal to the time threshold; If it is detected that the time used by the server middle layer to generate the page rendering file is greater than or equal to the preset time threshold, the resident cache database is used as the source of the target file; the life cycle of the resident cache database is longer than that of the temporary cache database; A target page loading module, configured to obtain the page rendering file from the source of the target file, and return the page rendering file to the client, so that the client can load and generate the target page according to the page rendering file.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method according to any one of claims 1-4.
7. An electronic device, characterized in that, Comprising: A processor; and A memory for storing executable instructions of the processor; Wherein, the processor is configured to execute the method according to any one of claims 1-4 by executing the executable instructions.
Citation Information
Patent Citations
Anomaly detection on web client
CN105531679A
Application program loading method and device, electronic equipment and readable storage medium
CN111666497A