A method and system for synthesizing web pages
By choosing between local storage and Redis cluster to obtain data, it solves the problems of difficult synchronization and poor disaster tolerance in web page synthesis, realizes dynamic rendering and diversified content presentation, and improves user experience.
Patent Information
- Application Number
- CN201910258259.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-04-01
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2039-04-01
AI Technical Summary
Existing web page synthesis methods are difficult to synchronize data or templates, have poor disaster recovery capabilities, cannot dynamically render web pages, and cannot present diversified content according to user needs.
By selecting between local storage and Redis cluster to obtain data, synchronize according to data status, realize multi-level disaster recovery, and dynamically select templates according to user requests to present different page content.
It improves the disaster recovery capability of web page data, decouples the data management and rendering parts, realizes dynamic rendering and diversified content presentation, and improves user experience.
Smart Images

Figure CN111767495B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and system for synthesizing web pages. Background Art
[0002] With the development of Internet and other technologies, users have more and more access to web pages, and the demand for personalized web pages is also increasing. Especially in the field of e-commerce, there are a large number of web pages such as the homepage, channel page, advertising page, and product detail page of e-commerce websites, and the corresponding website servers need to present different content according to user requests. Usually, these web pages are composed of predefined templates and application data filled in the templates. In this article, the predefined templates and application data are collectively referred to as data for synthesizing web pages.
[0003] At present, as the update speed of web pages is increasing day by day, the version of the template used to synthesize web pages is upgraded quickly, and the application data used to synthesize web pages may also be changed many times. On the other hand, in order to ensure the stability of the business, it is sometimes necessary to use the old version of the template to synthesize the web page, so it is necessary to maintain one or more templates used to synthesize web pages and the corresponding application data.
[0004] In actual application, it is found that the existing methods of realizing web page synthesis have at least the following problems: it is difficult to synchronize the application data or templates of the synthesized web page, and thus disaster recovery is impossible or the disaster recovery capability is poor. When some application data or templates change, the web page needs to be completely updated, and the template cannot be dynamically rendered, and it is impossible to simultaneously present diverse web page content according to user needs. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a method and system for synthesizing web pages, which can not only achieve multi-level disaster recovery for data used to synthesize web pages and greatly improve the disaster recovery capability of the system, but also adopt different templates according to user requests, thereby presenting different page contents to different users.
[0006] To achieve the above-mentioned purpose, a method for synthesizing a web page is provided according to a first aspect of an embodiment of the present invention, and the specific steps include: receiving a user request for obtaining a web page; according to the user request, querying the status of data used to synthesize the web page in the local storage, the status of the data including: the data has been updated, the data has expired, and the data does not exist; according to the status of the data, selecting to obtain the data from a Redis cluster or the local storage; and synthesizing the web page according to the data.
[0007] Optionally, it further includes: when the status of the data in the local storage is that the data has been updated, obtaining the data from the local storage; when the status of the data in the local storage is that the data has expired or the data does not exist, obtaining the data from the Redis cluster.
[0008] Optionally, the method further includes: when the data is not obtained from the Redis cluster, obtaining the data from the original storage.
[0009] Optionally, it further includes: when the data used to synthesize the web page changes, synchronizing the changed data from the original storage to the Redis cluster and the local storage; when the status of the data in the local storage is that the data is expired or the data does not exist, synchronizing the data used to synthesize the web page from the Redis cluster to the local storage.
[0010] Optionally, it further includes: judging the status of the data based on whether the difference between the current time and the timestamp of the data used to synthesize the web page in the local storage is greater than or equal to a threshold time interval: when the difference is not greater than the threshold time interval, judging the status of the data as the data has been updated; when the difference is greater than the threshold time interval, judging the status of the data as the data has expired.
[0011] Optionally, it further includes: judging the status of the data according to whether the timestamp of the data used to synthesize the web page in the Redis cluster is consistent with the timestamp of the data used to synthesize the web page in the local storage: when the timestamp of the data used to synthesize the web page in the Redis cluster is consistent with the timestamp of the data used to synthesize the web page in the local storage, judging the status of the data is that the data has been updated; when the timestamp of the data used to synthesize the web page in the Redis cluster is inconsistent with the timestamp of the data used to synthesize the web page in the local storage, judging the status of the data is that the data has expired.
[0012] Optionally, the method further includes: load balancing the user request to a web page synthesis server corresponding to the local storage according to information carried in the user request.
[0013] A second aspect of an embodiment of the present invention provides a system for synthesizing web pages, specifically comprising: a page synthesis server, a local storage, and a Reids cluster, wherein the local storage and the Reids cluster are used to store data for synthesizing web pages; the page synthesis server is used to receive user requests for obtaining web pages; the page synthesis server local storage queries the status of the data for synthesizing the web page in the local storage according to the user request, and the status of the data includes: the data has been updated, the data has expired, and the data does not exist; the page synthesis server chooses to obtain the data from the Redis cluster or the local storage according to the status of the data; the page synthesis server synthesizes the web page according to the data.
[0014] Optionally, it further includes: a dynamic service subsystem, when the status of the data in the local storage is that the data has been updated, the page synthesis server obtains the data from the local storage; when the status of the data in the local storage is that the data has expired or the data does not exist, the page synthesis server calls the dynamic service subsystem, and the dynamic service subsystem is used to obtain the data from the Redis cluster and synthesize the web page according to the data.
[0015] Optionally, it further includes: a content management subsystem, wherein the original storage of the content management subsystem is used to store the data for synthesizing the web page; when the data is not obtained from the Redis cluster, the dynamic service subsystem is used to obtain the data from the original storage.
[0016] Optionally, it further includes: a data synchronization subsystem, which is used to synchronize the changed data from the original storage to the Redis cluster and the local storage when the data used to synthesize the web page changes; when the status of the data in the local storage is that the data is expired or the data does not exist, the data synchronization subsystem is used to synchronize the data used to synthesize the web page from the Redis cluster to the local storage.
[0017] Optionally, the page synthesis server is used to determine the status of the data based on whether the difference between the current time and the timestamp of the data used to synthesize the web page in the local storage is greater than or equal to a threshold time interval: when the difference is not greater than the threshold time interval, the status of the data is determined to be that the data has been updated; when the difference is greater than the threshold time interval, the status of the data is determined to be that the data has expired.
[0018] Optionally, the page synthesis server is used to judge the status of the data based on whether the timestamp of the data used to synthesize the web page in the Redis cluster is consistent with the timestamp of the data used to synthesize the web page in the local storage: when the timestamp of the data used to synthesize the web page in the Redis cluster is consistent with the timestamp of the data used to synthesize the web page in the local storage, the status of the data is judged to be that the data has been updated; when the timestamp of the data used to synthesize the web page in the Redis cluster is inconsistent with the timestamp of the data used to synthesize the web page in the local storage, the status of the data is judged to be that the data has expired.
[0019] Optionally, it further includes: a load balancing server, wherein the load balancing server is used to load balance the user request to the web page synthesis server corresponding to the local storage according to the information carried in the user request.
[0020] To achieve the above-mentioned purpose, according to the third aspect of an embodiment of the present invention, a server for synthesizing web pages is provided, comprising: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement any of the methods for synthesizing web pages as described above.
[0021] To achieve the above objective, according to a fourth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any of the methods for synthesizing a web page as described above is implemented.
[0022] An embodiment of the above invention has the following advantages or beneficial effects: by selecting to obtain data for synthesizing web pages from a Redis cluster or from local storage according to the state of the data, other reliable data sources are provided when problems occur with the data in the local storage, thereby greatly improving the disaster recovery capability of the data used for synthesizing web pages; at the same time, the management part of the application data and the template and the assembly part of the application data and the template are decoupled, so that dynamic rendering of the template can be achieved according to user requests, providing the possibility of presenting multiple changes in the web page.
[0023] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0025] Figure 1 is a flow chart of a method for synthesizing a web page provided by an embodiment of the present invention;
[0026] Figure 2 is a flow chart of a method for synthesizing a web page provided by another embodiment of the present invention;
[0027] Figure 3 is a flow chart of a method for synthesizing a web page provided by another embodiment of the present invention;
[0028] Figure 4a , 4b is a flow chart of a method for synchronizing data for synthesizing a web page provided by an embodiment of the present invention, wherein Figure 4a It is a flowchart of the data synchronization method when the data in the original storage is changed. Figure 4b It is a flowchart of a data synchronization method according to the state of data in local storage;
[0029] Figure 5 is a schematic diagram of the structure of a system for synthesizing web pages provided by an embodiment of the present invention;
[0030] Figure 6 is a structural diagram of a system for synthesizing web pages provided by another embodiment of the present invention;
[0031] Figure 7 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0032] Figure 8 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0034] See also Figure 1 , an embodiment of the present invention provides a method for synthesizing a web page, the specific steps are as follows:
[0035] Step S101, receiving a user request for obtaining a web page;
[0036] The information carried by the user request indicates the data to be obtained for synthesizing the web page, and the data includes a template applied to the web page and application data filled in the template. For example, the user request indicates one or more of the following: the uniform resource locator (URL) of the web page to be accessed, version information of the web page to be accessed, the identifier of the user (User ID), the sending time of the user request, the receiving time of the user request, etc.
[0037] In a possible implementation, the user request can also be load balanced to the webpage synthesis server corresponding to the local storage according to the information carried in the user request. The information carried in the user request includes: URL, user ID, etc.; by using a hash algorithm or a consistent hash algorithm, the carried information such as URL, user ID, etc. is used as the KEY of the hash algorithm to calculate its hash value, and then user requests with the same hash value are distributed to webpage synthesis servers corresponding to different local storages, so as to improve the cache capacity of the local storage.
[0038] Step S102, according to the user request, querying the status of the data used to synthesize the web page in the local storage, the status of the data including: data updated, data expired, data does not exist;
[0039] Since the templates and application data used to synthesize web pages may change, the data in the local storage also needs to be changed synchronously accordingly. At the same time, due to the existence of various unexpected disasters such as equipment failure, communication failure, natural disasters, etc., the data in the local storage has multiple possible states, for example, data has been updated, data has expired, and data does not exist. Data has been updated means that the data in the local storage is consistent with the data in the Redis cluster, so the data in the local storage can be directly used to synthesize web pages; data has expired means that although there is data for synthesizing web pages in the local storage, the data is inconsistent with the corresponding data in the Redis cluster, so for this state, the data for synthesizing web pages should be obtained from the Redis cluster. In one embodiment, the consistency of the data can be determined by comparing the timestamp of the data in the local storage with the timestamp of the data in the Redis cluster. Data does not exist means that the data for synthesizing web pages has not yet been stored in the local storage, so for this state, the data for synthesizing web pages should also be obtained from the Redis cluster.
[0040] Step S103, according to the state of the data, select to obtain the data from the Redis cluster or the local storage;
[0041] According to the data status of the above query, it can be determined whether the data in the local storage can be used to synthesize the web page. If it is available, the data for synthesizing the web page can be directly obtained from the local storage; otherwise, in addition to obtaining the data for synthesizing the web page from the Redis cluster, in one embodiment, disaster recovery processing is also required, that is, synchronizing the data for synthesizing the web page from the Redis cluster to the local storage. This avoids using wrong data (templates and / or application data) to synthesize web pages, and also maintains the reliability of the data in the local storage, that is, improving the disaster recovery performance of the data, thereby improving the user experience.
[0042] Step S104, synthesizing the web page according to the data.
[0043] After obtaining reliable data for synthesizing pages from the Redis cluster or local storage, the template and application data in the obtained data are assembled to form a web page to be sent to the user.
[0044] The method for synthesizing web pages provided in this embodiment can not only obtain data for synthesizing web pages from local storage, but also obtain data for synthesizing web pages from the Redis cluster when the data in the local storage is not updated in time or no data is stored, that is, when it is inconsistent with the data in the Redis cluster, so as to ensure the reliability of the obtained data; at the same time, disaster recovery processing can also be performed, and data can be updated synchronously from the Redis cluster to the local storage, thereby greatly improving the disaster recovery performance of the data used for synthesizing web pages.
[0045] See also Figure 2 Based on the above embodiment, the embodiment of the present invention provides a method for synthesizing a web page. The above step S103, according to the state of the data, selects to obtain the data from the Redis cluster or the local storage, and may further include the following steps:
[0046] Step S1031, determining whether the state of the data is that the data has been updated;
[0047] On the basis of the aforementioned query status of the data used to synthesize the web page in the local storage, if the status of the queried data is that the data has been updated, it means that the data in the local storage is consistent with the data in the Redis cluster, and the data in the local storage can be used directly, so the following step S1032 can be executed; if the status of the queried data is that the data has expired or the data does not exist, it means that the data in the local storage has not been updated in time or the data used to synthesize the web page has not been stored in the local storage, that is, the data in the local storage is inconsistent with that in the Redis cluster, and thus the data used to synthesize the web page cannot be obtained from the local storage, and the following step S1033 needs to be executed; in one embodiment, whether the locally stored data is updated is determined based on whether the timestamp of the data used to synthesize the web page in the Redis cluster is consistent with the timestamp of the data used to synthesize the web page in the local storage.
[0048] Step S1032, obtaining the data from the local storage;
[0049] When the timestamp of the data used to synthesize the web page in the Redis cluster is consistent with the timestamp of the data used to synthesize the web page in the local storage, it is judged that the status of the data is that the data has been updated. At this time, the data in the local storage is consistent with the data in the Redis cluster, that is, the data in the local storage is available. Therefore, the data used to synthesize the web page is quickly obtained from the local storage, including the template and the application data filled in the template.
[0050] Step S1033, obtaining the data from the Redis cluster;
[0051] When the timestamp of the data used to synthesize the web page in the Redis cluster is inconsistent with the timestamp of the data used to synthesize the web page in the local storage, it is judged that the state of the data is not that the data has been updated. At this time, the data in the local storage is inconsistent with the data in the Redis cluster, that is, the data in the local storage is unavailable. Therefore, in order to obtain the correct data, the data is obtained from the Redis cluster. At the same time, in order to ensure the reliability of the data subsequently obtained from the local storage, disaster recovery processing is performed on the data in a timely manner, that is, the data used to synthesize the web page is synchronized from the Redis cluster to the local storage.
[0052] See also Figure 3 On the basis of the above embodiment, the embodiment of the present invention provides a method for synthesizing a web page, steps S101, S102, S103, S104, S1031, S1032, S1033 are all consistent with those in the above embodiment, and will not be described in detail here, except that the method further includes the following steps:
[0053] Step S1034, determining whether data is obtained from the Redis cluster;
[0054] When obtaining data for synthesizing web pages from the Redis cluster, there may be situations where data cannot be obtained, such as network interruption or data acquisition timeout. In order to be able to normally respond to the web pages requested by users, it is necessary to determine whether data for synthesizing web pages can be obtained from the Redis cluster, and then perform subsequent processing for different situations:
[0055] If the data is successfully obtained from the Redis cluster, step S104 can be directly executed to assemble the template for synthesizing the web page in the data and the application data template filled in the template into a web page.
[0056] If data cannot be obtained from the Redis cluster or fails to be obtained, the web page cannot be synthesized, and the following steps need to be performed:
[0057] Step S1035, obtaining the data from the original storage;
[0058] The data in the original storage is the direct source of the data that is synchronously updated in the Redis cluster and the local storage. Therefore, when the data for synthesizing the web page cannot be successfully obtained from the data in the local storage and the Redis cluster, the data for synthesizing the web page is directly obtained from the original storage to achieve multi-level disaster recovery performance of the data formed by the local storage, Redis cluster, and original storage when synthesizing the web page. At the same time, in order to ensure the reliability of the data obtained from the local storage and / or the Redis cluster when synthesizing the web page later, it is necessary to continue to perform disaster recovery processing on the data for synthesizing the web page, that is, to synchronize and update the data for synthesizing the web page in the original storage to the local storage and / or the Redis cluster.
[0059] It is worth noting that the methods for synthesizing web pages provided in the above embodiments decouple the management synchronization part of templates and application data and the assembly synthesis part of templates and application data in the process of synthesizing web pages, thereby reducing the mutual influence between the data management synchronization part and the assembly synthesis part. In particular, when a problem occurs in any part, it will not cause the other part to be unable to proceed, thereby providing possibilities for disaster recovery performance of data used to synthesize web pages and dynamic rendering of templates.
[0060] See also Figure 4a and Figure 4b Based on any of the above embodiments, an embodiment of the present invention provides a method for synchronizing data of a synthesized web page, which includes the following two cases:
[0061] See also Figure 4aWhen the data used to synthesize the web page changes, the changed data is synchronized from the original storage to the Redis cluster and the local storage. The specific steps are as follows:
[0062] Step S201, the data in the original storage is changed;
[0063] The data in the original storage includes templates and application data used to synthesize web pages. If any of the data changes, it is considered that the data in the original storage has changed. To ensure the reliability of the data used to synthesize web pages, it is necessary to synchronously update the data used to synthesize web pages in the local storage and the Redis cluster.
[0064] Step S202, synchronizing the changed data from the original storage to the Redis cluster or local storage;
[0065] When there is a change in the template or application data in the original storage, that is, when the data in the local storage and the Redis cluster are inconsistent with the data in the original storage, the changed data in the original storage is synchronized to the Redis cluster and / or the local storage. The changed data can be directly synchronized from the original storage to the Redis cluster or the local storage, or the changed data in the original storage can be synchronized to the Redis cluster first, and then synchronized from the Redis cluster to the local storage. And the full synchronization method can be adopted, and the incremental synchronization method can also be adopted. Based on this, the data in the local storage, Redis cluster and the original storage are always consistent, and thus the correctness of the acquired data for synthesizing web pages can be better ensured.
[0066] See also Figure 4b When the state of the data in the local storage is that the data has expired or does not exist, the data for synthesizing the web page is synchronized from the Redis cluster to the local storage, and the specific steps are as follows:
[0067] Step S301, querying the status of locally stored data, and the status of the data is that the data has expired or the data does not exist;
[0068] The query of the data status of the local storage described here can be either a passive query of the local storage caused by a user request, or a periodic active query set according to actual needs to ensure the reliability of the local storage data.
[0069] Step S302, synchronizing data for synthesizing a web page from the Redis cluster to the local storage;
[0070] When the status of the locally stored data is found to be updated, it is considered that the locally stored data is the latest version that has been updated and is directly available; when the status of the locally stored data is found to be expired or does not exist, that is, the locally stored data has not been synchronized and updated in time and is not the latest version, or the local storage is a newly added local storage or a blank local storage, the locally stored data is unavailable, and the data used to synthesize the web page needs to be synchronized from the Redis cluster so that the locally stored data after synchronization is available, thereby improving the efficiency of obtaining data used to synthesize the web page when synthesizing the web page.
[0071] In an optional implementation, based on any of the above embodiments, the method for synthesizing a web page provided by the embodiment of the present invention further includes: judging the state of the data according to whether the difference between the current time and the timestamp of the data used to synthesize the web page in the local storage is greater than or equal to a threshold time interval: if the difference is not greater than the threshold time interval, judging the state of the data as updated; if the difference is greater than the threshold time interval, judging the state of the data as expired. Specifically, taking the threshold time interval of 10s as an example, the difference between the current time and the latest timestamp of the data for synthesizing the web page stored locally is obtained. If the difference is not greater than the threshold time interval of 10s, judging the state of the data stored locally as updated, that is, the data is the latest version and is available; if the difference is greater than the threshold time interval of 10s, judging the state of the data stored locally as expired, that is, the data for synthesizing the web page is not synchronized and updated in time, is unavailable, and needs to be synchronized and updated from the Redis cluster.
[0072] In an optional embodiment, based on any of the above embodiments, the method for synthesizing web pages provided by the embodiments of the present invention further includes: judging the status of the data according to whether the timestamp of the data used to synthesize the web page in the Redis cluster is consistent with the timestamp of the data used to synthesize the web page in the local storage: when the timestamp of the data used to synthesize the web page in the Redis cluster is consistent with the timestamp of the data used to synthesize the web page in the local storage, judging the status of the data as updated; when the timestamp of the data used to synthesize the web page in the Redis cluster is inconsistent with the timestamp of the data used to synthesize the web page in the local storage, judging the status of the data as expired. Specifically, still taking the threshold time interval of 10s as an example, the latest timestamp of the data synchronization update for synthesizing the web page stored locally is subtracted from the latest timestamp of the data synchronization update for synthesizing the web page in the Redis cluster to obtain the difference between the two. If the difference is not greater than the threshold time interval of 10s, it is determined that the status of the locally stored data is that the data has been updated, that is, the data used for synthesizing the web page is the latest version and is available; if the difference is greater than the threshold time interval of 10s, it is determined that the status of the locally stored data is that the data is expired, that is, the data used for synthesizing the web page has not been synchronized and updated in time and is unavailable, and the data needs to be synchronized and updated from the Redis cluster.
[0073] See also Figure 5 An embodiment of the present invention provides a system for synthesizing web pages, including: a page synthesis server 1, a local storage 2, and a Reids cluster 3, wherein the local storage 2 and the Reids cluster 3 are used to store data for synthesizing web pages; the page synthesis server 1 is used to receive a user request for obtaining a web page; the local storage 2 of the page synthesis server 1 queries the status of the data for synthesizing the web page in the local storage 2 according to the user request, and the status of the data includes: the data has been updated, the data has expired, and the data does not exist; the page synthesis server 1 selects to obtain the data from the Redis cluster 3 or the local storage 2 according to the status of the data; the page synthesis server 1 synthesizes the web page according to the data.
[0074] Specifically, the page synthesis server 1 is taken as an Nginx page synthesis server as an example for explanation, and the corresponding local storage 2 is the Nginx local storage. In order to ensure the reliability of the data source and improve the disaster recovery performance of the data used for synthesizing web pages of the system, the Redis cluster 3 and the Nginx local storage are both used to store data for synthesizing web pages, including templates and application data filled in the templates, and the data in the Nginx local storage is kept consistent with the data in the Redis cluster 3 through synchronous updates, so the current state of the locally stored data may be that the data has been updated, the data has expired, or the data does not exist. After receiving a user request for synthesizing a web page, the Nginx page synthesis server preferentially queries the state of the data in the Nginx local storage, and when the state of the data is that the data has been updated, selects either the Redis cluster 3 or the Nginx local storage 2 to obtain the data for synthesizing the web page; when the state of the data is not that the data has been updated, that is, when the data has expired or the data does not exist, in order to ensure the reliability of the acquired data, the data for synthesizing the web page is directly obtained from the Redis cluster. After successfully acquiring the data for synthesizing a web page, the Nginx page synthesis server synthesizes the template and application data in the acquired data into a web page corresponding to the user request.
[0075] See also Figure 6 , an embodiment of the present invention provides a system for synthesizing web pages, and the system for synthesizing web pages, based on a page synthesis server 1, a local storage 2, and a Reids cluster 3, further includes: a load balancing server 7, and the load balancing server 7 is used to load balance the user request to the web page synthesis server 1 corresponding to the local storage 2 according to the information carried in the user request. The information carried by the user request includes the URL, the user ID, etc. Taking the load balancing using the consistent hashing algorithm as an example, the consistent hashing KEY uses the URL, and by calculating the hash value, the user requests with the same hash value will be assigned to the same page synthesis server 1 to improve the caching capacity of the corresponding local storage 2; and according to the URL and Cookie and other information, the page synthesis server 1 can obtain the corresponding template and application data from the Redis cluster 3 or the local storage 2.
[0076] See also Figure 5 and Figure 6In an optional implementation, based on the above embodiment, the page synthesis server 1 is used to determine the status of the data based on whether the difference between the current time and the timestamp of the data used to synthesize the web page in the local storage 2 is greater than or equal to a threshold time interval: when the difference is not greater than the threshold time interval, the status of the data is determined to be updated; when the difference is greater than the threshold time interval, the status of the data is determined to be expired.
[0077] See also Figure 5 and Figure 6 In an optional implementation, based on the above embodiment, the page synthesis server 1 is used to judge the status of the data according to whether the timestamp of the data used to synthesize the web page in the Redis cluster 3 is consistent with the timestamp of the data used to synthesize the web page in the local storage 2: when the timestamp of the data used to synthesize the web page in the Redis cluster 3 is consistent with the timestamp of the data used to synthesize the web page in the local storage 2, the status of the data is judged to be that the data has been updated; when the timestamp of the data used to synthesize the web page in the Redis cluster 3 is inconsistent with the timestamp of the data used to synthesize the web page in the local storage 2, the status of the data is judged to be that the data has expired.
[0078] See also Figure 6 An embodiment of the present invention provides a system for synthesizing web pages, which includes not only a page synthesis server 1, a local storage 2, and a Reids cluster 3, but also a dynamic service subsystem 4; when the status of the data in the local storage 2 is that the data has been updated, the page synthesis server 1 obtains the data from the local storage 2; when the status of the data in the local storage 2 is that the data has expired or does not exist, the page synthesis server 1 calls the dynamic service subsystem 4, and the dynamic service subsystem 4 is used to obtain the data from the Redis cluster 3 and synthesize the web page according to the data.
[0079] Specifically, the page synthesis server 1 is still taken as an Nginx page synthesis server for example, and the corresponding local storage 2 is Nginx local storage. After receiving a user request for synthesizing a web page, the Nginx page synthesis server first queries the status of the data in the Nginx local storage. When the status of the data is updated, the Nginx page synthesis server obtains the data from the Nginx local storage to synthesize the web page according to the data; when the status of the data is expired or does not exist, the Nginx page synthesis server directly calls the dynamic service subsystem 4, so that the dynamic service subsystem 4 directly accesses the Redis cluster to obtain the data and synthesize the web page according to the data.
[0080] See also Figure 6 An embodiment of the present invention provides a system for synthesizing web pages. The system for synthesizing web pages, based on a page synthesis server 1, a local storage 2, a Reids cluster 3, and a dynamic service subsystem 4, further includes: a content management subsystem 5, wherein the original storage 51 of the content management subsystem is used to store the data for synthesizing web pages; when the data is not obtained from the Redis cluster, the dynamic service subsystem is used to obtain the data from the original storage 51.
[0081] In order to improve the disaster recovery performance of the system for synthesizing web page data and realize multi-level disaster recovery of the data, the content management subsystem 5 includes: original storage 51, CMS module, data pipeline, etc.; wherein, the CMS module is used to edit and control the template and synchronize the template to the data pipeline, and the template is not a static file, but a piece of data, which will eventually be synchronized to the local storage 2; in addition to receiving changed templates, the data pipeline is also used to synchronize messages of application data changes in other databases subscribed by the system for synthesizing web pages; the original storage 51 is used to store templates published by the CMS module and application data received by the data pipeline, and the data in the Redis cluster 3 and the local storage 2 are consistent with the data in the original storage 51, that is, the data in the original storage 51 is the source of the data in the Redis cluster 3 and the local storage 2.
[0082] When the page synthesis server 1 calls the dynamic service subsystem 4, and the dynamic service subsystem 4 fails to obtain the data for synthesizing the web page from the Redis cluster 3, if a network failure occurs or the acquisition of data from the Redis cluster 3 times out, the dynamic service subsystem 4 can directly obtain the data for synthesizing the web page from the original storage 51, thereby realizing the multi-level disaster recovery performance of the system for synthesizing the web page.
[0083] See also Figure 6 , an embodiment of the present invention provides a system for synthesizing web pages. The system for synthesizing web pages, based on a page synthesis server 1, a local storage 2, a Reids cluster 3, a dynamic service subsystem 4, and a content management subsystem 5, further includes: a data synchronization subsystem 6. When the data used for synthesizing the web page changes, the data synchronization subsystem 6 is used to synchronize the changed data from the original storage 51 to the Redis cluster 3 and the local storage 2; when the status of the data in the local storage 2 is that the data is expired or does not exist, the data synchronization subsystem 6 is used to synchronize the data used for synthesizing the web page from the Redis cluster 3 to the local storage 2.
[0084] Specifically, when the template in the CMS module or the data pipeline receives a message indicating a change in the number of users, that is, when the data in the original storage 51 changes, the data synchronization subsystem 6 is used to synchronize the changed template or application data from the original storage 51 to the Redis cluster 3 and the local storage 2; when the page synthesis server 1 inquires that the data status of the local storage 2 is expired or does not exist, the data used for synthesizing the web page is timely processed for disaster recovery. At this time, the data synchronization subsystem 6 is used to synchronize and update the data from the Redis cluster 3 to the local storage 2. It is worth noting that the data synchronization subsystem 6 can either passively synchronize and update the data to the local storage 2 according to the status of the data after the page synthesis server 1 receives the user request, or actively synchronize and update the data to the local storage 2 according to the status of the data periodically queried according to actual needs to ensure the reliability of the locally stored data.
[0085] It is worth noting that, based on any of the above embodiments, the templates in the local storage may correspond to multiple versions of templates, including: official version, gray version, pre-release version. If the multiple versions of the templates are stored using a Hash structure, each of the official versions corresponds to the current time when the official version is stored as a timestamp, and the pre-release version and gray version each correspond to a predefined field or other conditions such as a password as a label, such as the pre-release version uses "predeploy" as a field, and the gray version uses "abVersion" as a field. In this way, multiple different versions can be distinguished.
[0086] According to the information corresponding to the timestamp and the tag carried in the user request, the page synthesis server can select the template of the corresponding version to be published. Specifically, if the user request only carries a URL, the page synthesis server can select the latest version of the template in the official version according to the timestamp sorting; if the user request only carries a URL and contains a "predeploy" field, the page synthesis server chooses to publish the corresponding pre-release version; if the user request only carries a URL and contains an "abVersion" field, the page synthesis server chooses to publish the corresponding gray version; for example, when a password or an intranet or an external network, an authority level, etc. are used as tags, if the page synthesis server recognizes that the received user request contains corresponding information, it selects the corresponding template version for publication.
[0087] Furthermore, based on the template multi-version storage, when a problem occurs in the current online version, the timestamp can be used to roll back to a historical version in the multiple versions to achieve version downgrade; when the problem is fixed, the current online version can be updated to the latest version. On the other hand, when the application data and the correct version of the template are successfully obtained, but the rendering template fails, such as encountering 500, 503 and other problems, the template can be rendered with the help of the multiple versions of the template, using the data of the previous version, and downgrading the template at this time to the previous historical version, thereby ensuring that the user can see the correctness of the data, thereby improving the user experience.
[0088] Specifically, based on any of the above embodiments, the present invention provides a method and system for synthesizing web pages, which can not only realize dynamic rendering of templates, but also realize rapid change, rollback, grayscale and presentation diversity of templates, etc., and at the same time, it can also realize high disaster tolerance of data when synthesizing web pages through a multi-level bottoming disaster recovery mechanism.
[0089] See also Figure 7The embodiment of the present invention also provides an exemplary system architecture 700 of a method or system for applying a composite web page, which may include: terminal devices 701, 702, 703, a network 704, and a server 705. The network 704 is used to provide a medium for a communication link between the terminal devices 701, 702, 703 and the server 705. The network 704 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0090] The user can use the terminal devices 701, 702, 703 to interact with the server 705 through the network 704 to receive or send messages, including sending user requests for synthesizing web pages, etc. The terminal devices 701, 702, 703 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, etc.
[0091] Server 705 may be a server that provides various services, such as a background management server that supports user requests sent by users using terminal devices 701, 702, and 703, a page synthesis server that receives user requests, a load balancing server that allocates user requests to page synthesis servers, and a local storage, Redi s The server where the cluster, original storage, etc. are located processes the user request sent by the user and provides a response (a web page synthesized according to the user request) to the terminal device.
[0092] It should be understood that Figure 7 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0093] refer to Figure 8 , which shows a schematic diagram of the structure of a computer system 800 of a terminal device suitable for implementing an embodiment of the present invention. Figure 8 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0094] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 802 or the program loaded from the storage part 808 to the random access memory (RAM) 803. In the RAM 803, various programs and data required for system operation are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0095] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage section 808 as needed.
[0096] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include 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 the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-mentioned functions defined in the system of the present invention are executed.
[0097] It should be noted that the computer-readable medium shown in the present invention 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 the present invention, 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 the present invention, 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: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0098] 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 invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a 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 box can also occur in a different order from the order marked in the accompanying drawings. For example, two 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 box in the block diagram or flow chart, and the combination of the boxes in the block diagram 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.
[0099] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules or subsystem blocks described may also be set in a processor.
[0100] As another aspect, the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: receiving a user request; obtaining data for synthesizing a web page according to the user request; synthesizing the data into a web page corresponding to the user request; and further, feeding back the synthesized web page to the user.
[0101] To sum up, according to the technical solution provided by the embodiment of the present invention, when synthesizing pages, not only can the bottom-up downgrade be used to achieve multi-level disaster recovery for synthesized data and maintenance of data reliability in local storage, but also the selection of multiple versions of templates for synthesizing pages can be used to achieve rollback of historical versions, grayscale release, etc., thereby improving user experience.
[0102] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for synthesizing web pages, It is characterized in that include: receiving a user request for obtaining a web page; According to the user request, querying the status of data used to synthesize the webpage in the local storage, the status of the data including: data updated, data expired, data does not exist; the data includes a template applied to the webpage and application data filled in the template, and the template of the webpage is decoupled from the application data; According to the state of the data, select to obtain the data from the Redis cluster or the local storage; Synthesizing the web page according to the data; specifically comprising: assembling the decoupled template and application data to form the web page; The templates in the local storage include: official version, gray version, and pre-release version; Acquiring the template from local storage includes: If the user request only carries a URL, the latest version of the template in the official version is selected based on the timestamp of the official version; if the user request only carries a URL and contains predefined fields, the corresponding grayscale version or pre-release version of the template is determined based on the predefined fields; if the user request contains information corresponding to a predefined tag, the template version corresponding to the predefined tag is selected.
2. The method for synthesizing a web page according to claim 1, It is characterized in that Further including: When the state of the data in the local storage is that the data has been updated, acquiring the data from the local storage; When the status of the data in the local storage is that the data is expired or does not exist, the data is obtained from the Redis cluster.
3. The method for synthesizing a web page according to claim 2, It is characterized in that Further including: When the data is not obtained from the Redis cluster, the data is obtained from the original storage.
4. The method for synthesizing a web page according to claim 3, It is characterized in that Further including: When the data used to synthesize the web page changes, synchronizing the changed data from the original storage to the Redis cluster and the local storage; When the status of the data in the local storage is that the data has expired or the data does not exist, the data for synthesizing the web page is synchronized from the Redis cluster to the local storage.
5. The method for synthesizing a web page according to claim 1, It is characterized in that Further including: The state of the data is determined according to whether the difference between the current time and the timestamp of the data in the local storage used to synthesize the webpage is greater than or equal to a threshold time interval: When the difference is not greater than the threshold time interval, determining that the state of the data is that the data has been updated; When the difference is greater than a threshold time interval, it is determined that the state of the data is expired.
6. The method for synthesizing a web page according to claim 1, It is characterized in that Further including: The state of the data is determined based on whether the timestamp of the data used to synthesize the web page in the Redis cluster is consistent with the timestamp of the data used to synthesize the web page in the local storage: When the timestamp of the data used to synthesize the webpage in the Redis cluster is consistent with the timestamp of the data used to synthesize the webpage in the local storage, determining that the state of the data is that the data has been updated; When the timestamp of the data used to synthesize the webpage in the Redis cluster is inconsistent with the timestamp of the data used to synthesize the webpage in the local storage, it is determined that the status of the data is expired.
7. The method for synthesizing a web page according to claim 1, It is characterized in that Further including: According to the information carried in the user request, the user request is load balanced to the web page synthesis server corresponding to the local storage.
8. A system for synthesizing web pages, It is characterized in that include: Page synthesis server, local storage, Reids cluster, including: The local storage and the Reids cluster are used to store data for synthesizing web pages; the data includes a template applied to the web page and application data filled in the template, and the template of the web page is decoupled from the application data; The page synthesis server is used to receive a user request for obtaining a web page; The page synthesis server locally stores, according to the user request, a state of the data used to synthesize the web page in the local storage, the state of the data including: the data has been updated, the data has expired, and the data does not exist; The page synthesis server selects to obtain the data from the Redis cluster or the local storage according to the state of the data; The page synthesis server synthesizes the web page according to the data; specifically, it is used to assemble the decoupled template and application data to form the web page; The templates in the local storage include: official version, gray version, and pre-release version; The page composition service obtains the template from the local storage including: If the user request only carries a URL, the latest version of the template in the official version is selected based on the timestamp of the official version; if the user request only carries a URL and contains predefined fields, the corresponding grayscale version or pre-release version of the template is determined based on the predefined fields; if the user request contains information corresponding to a predefined tag, the template version corresponding to the predefined tag is selected.
9. The system for synthesizing web pages according to claim 8, It is characterized in that Further including: Dynamic service subsystem, When the state of the data in the local storage is that the data has been updated, the page synthesis server obtains the data from the local storage; When the status of the data in the local storage is that the data has expired or does not exist, the page synthesis server calls the dynamic service subsystem, and the dynamic service subsystem is used to obtain the data from the Redis cluster and synthesize the web page according to the data.
10. The system for synthesizing web pages according to claim 8, It is characterized in that Further including: A content management subsystem, wherein the original storage of the content management subsystem is used to store the data for synthesizing the web page; When the data is not obtained from the Redis cluster, the dynamic service subsystem is used to obtain the data from the original storage.
11. The system for synthesizing web pages according to claim 10, It is characterized in that Further including: Data synchronization subsystem, When the data used to synthesize the web page changes, the data synchronization subsystem is used to synchronize the changed data from the original storage to the Redis cluster and the local storage; When the status of the data in the local storage is that the data has expired or the data does not exist, the data synchronization subsystem is used to synchronize the data used to synthesize the web page from the Redis cluster to the local storage.
12. The system for synthesizing web pages according to claim 8, It is characterized in that The page synthesis server is used to determine the state of the data according to whether the difference between the current time and the timestamp of the data used to synthesize the web page in the local storage is greater than or equal to a threshold time interval: When the difference is not greater than the threshold time interval, determining that the state of the data is that the data has been updated; When the difference is greater than a threshold time interval, it is determined that the state of the data is expired.
13. The system for synthesizing web pages according to claim 8, It is characterized in that The page synthesis server is used to determine the state of the data according to whether the timestamp of the data used to synthesize the web page in the Redis cluster is consistent with the timestamp of the data used to synthesize the web page in the local storage: When the timestamp of the data used to synthesize the webpage in the Redis cluster is consistent with the timestamp of the data used to synthesize the webpage in the local storage, determining that the state of the data is that the data has been updated; When the timestamp of the data used to synthesize the webpage in the Redis cluster is inconsistent with the timestamp of the data used to synthesize the webpage in the local storage, it is determined that the status of the data is expired.
14. The system for synthesizing web pages according to claim 8, It is characterized in that Further including: A load balancing server is used to load balance the user request to the web page synthesis server corresponding to the local storage according to the information carried in the user request.
15. A server for synthesizing web pages, It is characterized in that include: one or more processors; a storage device for storing one or more programs, 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 7.
16. A computer readable medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Designing and acquiring method for delayed personalized web page
CN101488135A
Webpage browsing method for mobile terminal and mobile terminal applying same
CN102033917A
Data processing method and device
CN104537013A
Webpage data acquiring method and device
CN104615771A
B / S mode based dynamic webpage generation method, server, and system
CN106227742A
