Page theme resource processing method, electronic equipment, medium and product
By caching the client's page theme update request in the reverse proxy server, and obtaining personalized theme resources from the server based on the theme identity and user identity, the problem of slow response speed when obtaining page theme resources is solved, and the user experience is improved.
Patent Information
- Application Number
- CN202411665719.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-04-15
AI Technical Summary
When obtaining page theme resources, network problems or too large resources may cause users to respond too slowly when opening the web page or render for a long time, affecting the user experience.
By receiving the client's page topic update request in the reverse proxy server, obtaining personalized topic resources from the server based on the topic identity and user identity, and generating cache key-value pairs for cache, reducing server load and improving response time.
By caching users' personalized theme resources, the load on the server is reduced, the page response time is improved, and differentiating different users and personalized theme resources are avoided by caching data.
Smart Images

Figure CN119835319A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Internet technology, and in particular to a method for processing page theme resources, electronic equipment, medium and product. Background Art
[0002] With the rapid development of Internet technology, when a user opens a web page of a platform through a client, the client will obtain the page theme resources from the server where the platform is located to render and display them on the client's interactive interface.
[0003] However, when obtaining page theme resources, due to network problems or when the page theme resources are too large, when the user opens the webpage, the page in the interactive interface responds too slowly or takes a long time to render, thus affecting the user experience. Summary of the invention
[0004] In view of the above problems, a method for processing page theme resources, an electronic device, a medium and a product are proposed to overcome the above problems or at least partially solve the above problems, including:
[0005] A method for processing page theme resources is applied to a reverse proxy server, wherein the reverse proxy server is respectively connected to a server and multiple clients for communication, and the method comprises:
[0006] Receive a page theme update request from any client; wherein the page theme update request includes a theme identifier and a user identifier of the client;
[0007] Acquire personalized subject resources from the server according to the subject identifier and the user identifier;
[0008] A cache key-value pair is generated according to the subject identifier and the user identifier, and the personalized subject resource is cached according to the cache key-value pair.
[0009] Optionally, the personalized subject resource is obtained by the server performing personalized adjustment on the subject resource corresponding to the subject identifier according to user attribute data corresponding to the user identifier.
[0010] Optionally, it also includes:
[0011] Receive a page acquisition request from a target client; wherein the page acquisition request includes a target subject identifier and a target user identifier of the target client;
[0012] Generate a target cache key-value pair according to the target subject identifier and the target user identifier, and use the target cache key-value pair to determine a target personalized subject resource from the cache;
[0013] A target page is generated according to the target personalized subject resource, and the target page is sent to the target client so as to be presented on the target client.
[0014] Optionally, the page acquisition request further includes a page identifier, and the generating of a target page according to the target personalized subject resource includes:
[0015] Obtaining the page content corresponding to the page identifier from the server;
[0016] Generate a target page based on the target personalized subject resources and page content.
[0017] Optionally, it also includes:
[0018] A cache expiration time is set for the data cached in the reverse proxy server, and when it is detected that the cache time of the data reaches the cache expiration time, the cached data is updated.
[0019] Optionally, the data cached in the reverse proxy server includes static data and dynamic data, and the cache expiration time of the static data is greater than the cache expiration time of the dynamic data.
[0020] Optionally, the static data includes personalized theme resources, and the dynamic data includes page content.
[0021] Optionally, when detecting that the cache duration of the data reaches the cache expiration duration, updating the cached data includes:
[0022] When it is detected that the cache duration of the personalized theme resource reaches the cache expiration duration, a new personalized theme resource is obtained from the server to update the cached personalized theme resource.
[0023] Optionally, it also includes:
[0024] When it is detected that the theme resource corresponding to the theme identifier changes, a new personalized theme resource is obtained from the server to update the cached personalized theme resource.
[0025] An electronic device comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the method described above when executed by the processor.
[0026] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0027] A computer program product comprises a computer program, wherein when the computer program is executed by a processor, the computer program implements the method as described above.
[0028] The embodiments of the present invention have the following advantages:
[0029] In an embodiment of the present invention, a reverse proxy server is set up, and the reverse proxy server receives a page theme update request from any client; wherein the page theme update request includes a theme identifier and a user identifier of the client; a personalized theme resource is obtained from the server according to the theme identifier and the user identifier; a cache key-value pair is generated according to the theme identifier and the user identifier, and the personalized theme resource is cached according to the cache key-value pair, thereby caching the user's personalized theme resources through the reverse proxy server, reducing the load on the server, improving the response time of the page, and distinguishing different users and personalized theme resources according to the cache key-value pair, thereby avoiding confusion of cached data. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0031] Figure 1 It is a flowchart of the steps of a method for processing page theme resources provided by some embodiments of the present invention;
[0032] Figure 2 is a configuration flow chart of a reverse proxy server provided by some embodiments of the present invention;
[0033] Figure 3 It is a step flow chart of another method for processing page theme resources provided by some embodiments of the present invention. DETAILED DESCRIPTION
[0034] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0035] In order to improve user experience, the embodiment of the present invention introduces a reverse proxy server, which is located between the client and the server, is responsible for caching and distributing static data, and dynamically generating pages. It also generates a unique cache key-value pair based on the user identifier and the subject identifier to distinguish different users and different page subjects. The design of the cache key-value pair can avoid cache conflicts and improve the cache hit rate.
[0036] For example, when a user visits a page, the reverse proxy server can first obtain data from the cache. If the data exists in the cache, it will directly respond to the user, thereby speeding up the response time and reducing the server load. If the data does not exist in the cache, it will be obtained from the server. However, sometimes the data exists in the cache, but the identification is invalid. The cache key-value pair can be used to improve the cache hit rate.
[0037] By configuring the reverse proxy server, adopting multiple cache consistency strategies, and setting a reasonable cache expiration time, we can ensure that the cache content can be automatically updated after it expires, and the relevant cache will be actively refreshed when the page theme is switched; using the version control mechanism, we can manage the page theme resources and force the cache to be updated to ensure that the page is rendered in time to prevent expired pages from causing a negative experience.
[0038] The present invention will be further described below in conjunction with the accompanying drawings:
[0039] Reference Figure 1 , showing a step flow chart of a method for processing page theme resources provided by some embodiments of the present invention, which is applied to a reverse proxy server, and the reverse proxy server is respectively communicated with a server and multiple clients.
[0040] As some examples, a page can be a web page, which refers to a page consisting of a series of text, images, audio, video, etc. The theme of a page is a design concept that defines the visual style and layout of a website, including color schemes, fonts, images, and layout.
[0041] For example, page themes can include: classic blue and white theme, light color theme, modern theme, retro theme, child theme, high contrast theme, etc.
[0042] As some examples, a reverse proxy server can be deployed between multiple clients and servers. The reverse proxy server can forward client requests to the server. After the server processes the request, it sends the response result back to the reverse proxy server, and the reverse proxy server returns the result to the client.
[0043] For example, when deploying a reverse proxy server, you can edit the configuration file to define its proxy rules, such as path modification, changing the / desk / in the URL (Uniform Resource Locator) path of the user's request to / backend / desk / before transmitting it to the server; restricting access, such as requiring certain parameters to access certain resources; ensuring security, using firewalls to filter certain malicious requests, preventing security threats such as SQL (Structured Query Language) injection, and preventing DDoS (Distributed Denial of Service) attacks.
[0044] Specifically, the following steps may be included:
[0045] Step 101, receiving a page theme update request from any client; wherein the page theme update request includes a theme identifier and a user identifier of the client.
[0046] In actual applications, users can switch page themes according to their needs; for example, users need to switch different themes according to the current light and select the theme that best suits the current color tone, or switch to select the most suitable theme to meet the current scene, or switch themes to meet their functional needs, etc.
[0047] As some examples, the user can switch the page theme in the client according to the page theme resource library provided by the platform. For example, when the user triggers the operation of switching the page theme, such as the user switches the current page theme (A) to the page theme (B), the client can send a page theme update request to the reverse proxy server.
[0048] In some examples, the page theme update request may include a theme identifier and a user identifier of the client. Each page theme has a corresponding page theme resource and a corresponding unique theme identifier; for example, if the page theme is a light-tone theme, the theme identifier of the light-tone theme is QSD001. The user identifier of the client is the identity document (ID) created when the user logs into the platform. The user identifier can be a user's mobile phone number, a unique string, etc. Each user's user identifier is unique.
[0049] For example, after a user logs in to a website or platform by entering his / her user ID and password through the client, he / she can switch the page theme of the platform page according to personal needs. When the page theme switching operation is triggered, the client sends a page theme update request to the reverse proxy server, so that the reverse proxy server obtains the page theme resources from the server according to the page theme update request.
[0050] Step 102: Obtain personalized theme resources from the server according to the theme identifier and the user identifier.
[0051] In some embodiments of the present invention, the personalized subject resource is obtained by the server performing personalized adjustment on the subject resource corresponding to the subject identifier according to the user attribute data corresponding to the user identifier.
[0052] As some examples, after receiving a page theme update request, the reverse proxy server may forward it to the server, and the server determines the page theme resource corresponding to the theme identifier based on the theme identifier carried in the page theme update request.
[0053] In some examples, the personalized theme resource is obtained by the server after personalizing the theme resource corresponding to the theme identifier according to the user attribute data corresponding to the user identifier; wherein the user attribute data may be the user's historical operation data; for example, when user 001 switches page theme A to page theme B, the layout or style of the switched page theme B may be adjusted, and these adjustment operations may be used as the historical operation data of user 001; after the user adjusts page theme B, a layout strategy for page theme B may be generated based on the historical operation data and stored on the server.
[0054] After the server determines the page theme resource corresponding to the theme identifier based on the theme identifier carried in the page theme update request, it can determine the corresponding user attribute data based on the user identifier carried in the page theme update request, so as to find the layout strategy for the page theme based on the user attribute data, and determine the user's personalized theme resource, thereby sending the personalized theme resource to the reverse proxy server for caching.
[0055] Step 103: Generate a cache key-value pair according to the subject identifier and the user identifier, and cache the personalized subject resource according to the cache key-value pair.
[0056] In some examples, a key-value pair is an implementation of a mapping in a mathematical concept in a programming language, where the key is used as an index of an element and the value represents the data stored and read; and a cache key-value pair can be used to identify the uniqueness of each cached data, thereby caching personalized theme resources set by the user through the cache key-value pair.
[0057] For example, after the reverse proxy server obtains the personalized theme resource from the server, it can generate a unique cache key-value pair for caching the personalized theme resource based on the theme identifier and user identifier in the page theme update request, and cache the personalized theme resource based on the cache key-value pair. The cache key-value pair can be used to effectively distinguish different users and different page themes, and the cache key-value pair can effectively avoid cache conflicts and improve cache hit rates.
[0058] As some examples, a cache area can be defined in the reverse proxy server for caching personalized theme resources, and rules for generating cache key-value pairs can be defined, such as using the client host name + request URL + user ID + theme ID to generate a cache key-value pair; when a page theme update request is received from any client, a cache key-value pair is generated according to the rules for generating cache key-value pairs, and the obtained personalized theme resources are cached in the corresponding cache area according to the cache key-value pair.
[0059] In some embodiments of the present invention, the method further includes: when it is detected that the theme resource corresponding to the theme identifier changes, obtaining a new personalized theme resource from the server to update the cached personalized theme resource.
[0060] As some examples, when the page content or subject resources change, the notification mechanism in the reverse proxy server will actively refresh the cache area, actively clear expired caches through the data in the API and message queue, and update the latest cache data; when a change is detected in the subject resource corresponding to the subject identifier, the reverse proxy server can send an update request to the server, which can carry the subject identifier, user identifier, and page identifier, so that the server can personalize the subject resource corresponding to the subject identifier according to the user attribute data corresponding to the user identifier, obtain a new personalized subject resource, and send it to the reverse proxy server to update the previously cached personalized subject resource.
[0061] In some embodiments of the present invention, it also includes: receiving a page acquisition request from a target client; wherein the page acquisition request includes a target subject identifier and a target user identifier of the target client; generating a target cache key-value pair based on the target subject identifier and the target user identifier, and using the target cache key-value pair to determine a target personalized subject resource from the cache; generating a target page based on the target personalized subject resource, and sending the target page to the target client to present the target page on the target client.
[0062] In actual applications, when a user enters a website or logs in to a platform through a client or switches pages on the website / platform, the client generates a page acquisition request to send to the reverse proxy server to obtain the page presented to the user by the website or platform.
[0063] For example, when user A is the target user and logs into a website or platform on the client, the client, as the target client of user A, will send a page acquisition request to the reverse proxy server. The page acquisition request includes the target subject identifier and the target user identifier of the target client; the target subject identifier is the subject identifier corresponding to the target subject selected by the target user, and the target user identifier is the target user ID when the target user logs in to the website / platform.
[0064] After a user successfully logs in to a website or platform through a client and the reverse proxy server receives a page acquisition request, it can generate a target cache key-value pair based on the target subject identifier and the target user identifier according to the rules for generating cache key-value pairs, and use the target cache key-value pair to search for the target personalized subject resource from the cache area of the reverse proxy server; then it generates a target page based on the target personalized subject resource, and sends the target page to the target client to present the target page on the target client.
[0065] In some embodiments of the present invention, the page acquisition request also includes a page identifier, and generating a target page based on the target personalized subject resource includes: obtaining page content corresponding to the page identifier from the server; and generating the target page based on the target personalized subject resource and the page content.
[0066] As some examples, a page acquisition request includes a page identifier, which may be a page identifier, which refers to an identifier used to uniquely identify an element or location in a web page. In a URL, a page identifier is typically composed of the “#” symbol and the characters following it; for example, #print in http: / / www.xxx.com / xxx.xxx#print is a page identifier.
[0067] After the reverse proxy server receives the page acquisition request from the target client, it can parse the page identifier and then obtain the page content corresponding to the page identifier in the server according to the page identifier; combined with the target personalized theme resource found in the cache area of the reverse proxy server and the page content corresponding to the page identifier obtained from the server, it is rendered to generate the target page.
[0068] In some embodiments of the present invention, the method further includes: setting a cache expiration time for the data cached in the reverse proxy server, and updating the cached data when it is detected that the cache time for the data reaches the cache expiration time.
[0069] As some examples, the cache expiration time may be the cache time, such as 7 days; the cache time refers to the length of time that the content is stored in the cache and can be reused.
[0070] After generating the target page based on the target personalized subject resources and page content, the reverse proxy server can also cache the data in the target page according to a pre-set cache strategy, and cache the data to the corresponding cache area according to the target cache key-value pair.
[0071] In some examples, the pre-set cache strategy may include parameters such as cache path, cache name, cache boundary value, and cache time; among which, the cache boundary value refers to certain restrictions and thresholds set in the cache configuration, such as the size of the cache file, the cache expiration time, the cache area size, the number of times the cache is used, etc.
[0072] In actual applications, in order to update the cached data in a timely manner, improve resource utilization and the real-time nature of page content, you can set a cache expiration time for the cached data to ensure that the cached data automatically expires and is updated in a timely manner after a period of time. When it is detected that the cache time of the cached data reaches the cache expiration time, the reverse proxy server can send an update request to the server to update the current cached data in a timely manner.
[0073] In some examples, the data cache expiration time can be set according to the response status code returned by the server; different cache expiration times can also be set according to the type of data in the page content, such as static data and dynamic data.
[0074] As some examples, when the reverse proxy server obtains the page content corresponding to the page identifier from the server according to the page acquisition request, the server can also reply to the reverse proxy server with an HTTP response status code to indicate the processing result of the request; for example, the 200 status code indicates that the request is successful, while the 404 status code indicates that the requested data is not found.
[0075] After the reverse proxy server receives the response status code, it can set different cache expiration times for the acquired data according to different response status codes, so that when the client requests the same data again, the data can be given to the client in time without having to be generated from the server again.
[0076] For example, a longer cache time (such as 200 and 302 redirects) can be set for successful requests and requests with relatively stable data. A 7-day cache time can be set for data with a response status code of 200, so that the data can be reused over a longer period of time without having to request it from the server again. A shorter cache time can be set for temporary requests (404 Not Found). A 5-minute cache time or even no caching can be set for data with a response status code of 404.
[0077] In some embodiments of the present invention, the data cached in the reverse proxy server includes static data and dynamic data, and the cache expiration time of the static data is greater than the cache expiration time of the dynamic data.
[0078] In some embodiments of the present invention, the static data includes personalized theme resources, and the dynamic data includes page content.
[0079] In some examples, static data may be resources that do not change each time a request occurs, such as image files (PNG, GIF, JPG images), font files (WOFF, TTF fonts), video and audio files, etc., and dynamic data may be dynamic web pages (front-end Vue, PHP pages), result web pages generated by user searches, returned personalized recommendation data, etc.
[0080] Among them, since static data rarely changes, a longer cache expiration time can be set; while dynamic data may change frequently due to some factors, a shorter cache expiration time can be set; for example, a cache time of 7 days is set for static data, and a cache time of 10 minutes is set for dynamic data.
[0081] As some examples, the reverse proxy server can be configured to distinguish the type of cached data, so as to set the cache expiration time; for example, it can be distinguished by file extension, header information in the response, request parameters, parameters in the URL path, etc., and static data and dynamic data can be stored in corresponding specific directories; after identification, the cache can be configured to set the corresponding cache time according to the update frequency of the data, and static data can also be compressed to reduce the file size, improve transmission efficiency and data reuse rate. For dynamic data, a shorter cache time can be set to reduce the load on the reverse proxy server and ensure the real-time nature of the data.
[0082] In some embodiments of the present invention, when it is detected that the cache time of the data reaches the cache expiration time, the cached data is updated, including: when it is detected that the cache time of the personalized theme resource reaches the cache expiration time, a new personalized theme resource is obtained from the server to update the cached personalized theme resource.
[0083] As some examples, the reverse proxy server can also detect data in the cache area. When it is detected that the cache duration of personalized theme resources in the cache area reaches the cache expiration duration, a new personalized theme resource can be obtained from the server based on the cache key-value pair to replace the current personalized theme resource with the new personalized theme resource and set the cache expiration duration of the new personalized theme resource.
[0084] In an embodiment of the present invention, a reverse proxy server is set up, and the reverse proxy server receives a page theme update request from any client; wherein the page theme update request includes a theme identifier and a user identifier of the client; a personalized theme resource is obtained from the server according to the theme identifier and the user identifier; a cache key-value pair is generated according to the theme identifier and the user identifier, and the personalized theme resource is cached according to the cache key-value pair, thereby caching the user's personalized theme resources through the reverse proxy server, reducing the load on the server, improving the response time of the page, and distinguishing different users and personalized theme resources according to the cache key-value pair, thereby avoiding confusion of cached data.
[0085] The following combination Figure 2 The present invention is exemplified as follows:
[0086] Step 201, deploy a reverse proxy server.
[0087] For example, a reverse proxy server is deployed between multiple clients and servers. The reverse proxy server can forward client requests to the server. After the server processes the request, it sends the response result back to the reverse proxy server, and the reverse proxy server then returns the result to the client.
[0088] Step 202: configure the reverse proxy server.
[0089] For example, when deploying a reverse proxy server, you can edit the configuration file to define its proxy rules, such as path modification, changing the / desk / in the URL (Uniform Resource Locator) path of the user's request to / backend / desk / before transmitting it to the server; restricting access, such as requiring certain parameters to access certain resources; ensuring security, using firewalls to filter certain malicious requests, preventing security threats such as SQL (Structured Query Language) injection, and preventing DDoS (Distributed Denial of Service) attacks.
[0090] Step 203, identifying and distinguishing static data from dynamic data.
[0091] For example, the reverse proxy server can be configured to distinguish the type of cached data, so as to set the cache expiration time; for example, it can distinguish by file extension, header information in the response, request parameters, parameters in the URL path, etc., and store static data and dynamic data in corresponding specific directories; after identification, the cache can be configured to set the corresponding cache time according to the update frequency of the data, and static data can also be compressed to reduce the file size, improve transmission efficiency and data reuse rate. For dynamic data, a shorter cache time can be set to reduce the load on the reverse proxy server and ensure the real-time nature of the data.
[0092] Among them, static data can be resources that do not change each time a request occurs, such as image files (PNG, GIF, JPG pictures), font files (WOFF, TTF fonts), video and audio files, etc. Dynamic data can be dynamic web pages (front-end Vue, PHP pages), result web pages generated by user searches, returned personalized recommendation data, etc.
[0093] Among them, since static data rarely changes, a longer cache expiration time can be set; while dynamic data may change frequently due to some factors, a shorter cache expiration time can be set; for example, a cache time of 7 days is set for static data, and a cache time of 10 minutes is set for dynamic data.
[0094] In actual applications, in order to effectively identify and distinguish static data from dynamic data, the request route can be set to the static data processing module and server. This process can be implemented through the location and directory instructions in the configuration file. The request route can also be set to the static data server or cache for identification.
[0095] As some examples, in order to reduce the load on the reverse proxy server and improve the user experience, data can be cached to multiple nodes around the world to form a distributed network to improve resource availability and access speed. If the content volume is too large, it can also be compressed to improve transmission efficiency.
[0096] Step 204: Perform version management on the theme resource and force the cache to be updated.
[0097] Among them, the version management of theme resources can be managed by front-end developers or back-end developers. If there are a large number of old caches in the theme resources, it will cause memory block overflow. In order to avoid this phenomenon, the administrator will update the iterative version of resource management. Each update to the system will have a record of modified data for subsequent inspection or version rollback.
[0098] Step 205, configure personalized cache to ensure that different theme update requests generate corresponding cache key-value pairs.
[0099] For example, after a user logs in to a website or platform by entering his / her user ID and password through the client, he / she can switch the page theme of the platform page according to personal needs. When the page theme switching operation is triggered, the client sends a page theme update request to the reverse proxy server, so that the reverse proxy server obtains the page theme resources from the server according to the page theme update request.
[0100] After the server determines the page theme resource corresponding to the theme identifier based on the theme identifier carried in the page theme update request, it then determines the corresponding user attribute data based on the user identifier carried in the page theme update request, so as to find the layout strategy for the page theme based on the user attribute data, and determine the user's personalized theme resource, thereby sending the personalized theme resource to the reverse proxy server for caching.
[0101] After the reverse proxy server obtains the personalized theme resource from the server, it can generate a unique cache key-value pair for caching the personalized theme resource according to the theme identifier and user identifier in the page theme update request, and cache the personalized theme resource according to the cache key-value pair. The cache key-value pair can be used to effectively distinguish different users and different page themes, and the cache key-value pair can effectively avoid cache conflicts and improve cache hit rate.
[0102] As some examples, a cache area can be defined in the reverse proxy server for caching personalized theme resources, and rules for generating cache key-value pairs can be defined, such as using the client host name + request URL + user ID + theme ID to generate a cache key-value pair; when a page theme update request is received from any client, a cache key-value pair is generated according to the rules for generating cache key-value pairs, and the obtained personalized theme resources are cached in the corresponding cache area according to the cache key-value pair.
[0103] Step 206: monitor response performance and optimize cache strategy.
[0104] Collect and analyze client response time and dynamically adjust cache strategies based on data to improve performance and response speed, reduce server load, and provide higher availability and reliability.
[0105] In some examples, a cache strategy can be set in advance, and the pre-set cache strategy can include parameters such as cache path, cache name, cache boundary value, and cache time; among which, the cache boundary value refers to certain restrictions and thresholds set in the cache configuration, such as the size of the cache file, the cache expiration time, the cache area size, the number of times the cache is used, etc.
[0106] In actual applications, in order to update the cached data in a timely manner, improve resource utilization and the real-time nature of page content, you can set a cache expiration time for the cached data to ensure that the cached data automatically expires and is updated in a timely manner after a period of time. When it is detected that the cache time of the cached data reaches the cache expiration time, the reverse proxy server can send an update request to the server to update the current cached data in a timely manner.
[0107] In some examples, the cache expiration time of data can be set according to the response status code returned by the server; different cache expiration times can also be set according to the type of data in the page content, such as static data and dynamic data. Among them, since static data rarely changes, a longer cache expiration time can be set; and dynamic data may change frequently due to some factors, so a shorter cache expiration time can be set; for example, a 7-day cache time is set for static data and a 10-minute cache time is set for dynamic data.
[0108] As some examples, when the reverse proxy server obtains the page content corresponding to the page identifier from the server according to the page acquisition request, the server can also reply to the reverse proxy server with an HTTP response status code to indicate the processing result of the request; for example, the 200 status code indicates that the request is successful, while the 404 status code indicates that the requested data is not found.
[0109] After the reverse proxy server receives the response status code, it can set different cache expiration times for the acquired data according to different response status codes, so that when the client requests the same data again, the data can be given to the client in time without having to be generated from the server again.
[0110] For example, a longer cache time (such as 200 and 302 redirects) can be set for successful requests and requests with relatively stable data. A 7-day cache time can be set for data with a response status code of 200, so that the data can be reused over a longer period of time without having to request it from the server again. A shorter cache time can be set for temporary requests (404 Not Found). A 5-minute cache time or even no caching can be set for data with a response status code of 404.
[0111] Reference Figure 3 , showing a step flow chart of another method for processing page theme resources provided by some embodiments of the present invention, which is applied to a reverse proxy server, and the reverse proxy server is respectively communicated with a server and multiple clients.
[0112] As some examples, a page can be a web page, which is composed of a series of text, images, audio, video, etc. The theme of a page is a design concept that defines the visual style and layout of a website, including color schemes, fonts, images, and layout.
[0113] For example, page themes can include: classic blue and white theme, light color theme, modern theme, retro theme, child theme, high contrast theme, etc.
[0114] As some examples, a reverse proxy server can be deployed between multiple clients and servers. The reverse proxy server can forward client requests to the server. After the server processes the request, it sends the response result back to the reverse proxy server, and the reverse proxy server returns the result to the client.
[0115] For example, when deploying a reverse proxy server, you can edit the configuration file to define its proxy rules, such as path modification, changing the / desk / in the URL (Uniform Resource Locator) path of the user's request to / backend / desk / before transmitting it to the server; restricting access, such as requiring certain parameters to access certain resources; ensuring security, using firewalls to filter certain malicious requests, preventing security threats such as SQL (Structured Query Language) injection, and preventing DDoS (Distributed Denial of Service) attacks.
[0116] Specifically, the following steps may be included:
[0117] Step 301, receiving a page theme update request from any client; wherein the page theme update request includes a theme identifier and a user identifier of the client.
[0118] In actual applications, users can switch page themes according to their needs; for example, users need to switch different themes according to the current light and select the theme that best suits the current color tone, or switch to select the most suitable theme to meet the current scene, or switch themes to meet their functional needs, etc.
[0119] As some examples, the user can switch the page theme in the client according to the page theme resource library provided by the platform. For example, when the user triggers the operation of switching the page theme, such as the user switches the current page theme (A) to the page theme (B), the client can send a page theme update request to the reverse proxy server.
[0120] In some examples, the page theme update request may include a theme identifier and a user identifier of the client. Each page theme has a corresponding page theme resource and a corresponding unique theme identifier; for example, if the page theme is a light-tone theme, the theme identifier of the light-tone theme is QSD001. The user identifier of the client is the identity document (ID) created when the user logs into the platform. The user identifier can be a user's mobile phone number, a unique string, etc. Each user's user identifier is unique.
[0121] For example, after a user logs in to a website or platform by entering his / her user ID and password through the client, he / she can switch the page theme of the platform page according to personal needs. When the page theme switching operation is triggered, the client sends a page theme update request to the reverse proxy server, so that the reverse proxy server obtains the page theme resources from the server according to the page theme update request.
[0122] Step 302: Obtain personalized theme resources from the server according to the theme identifier and the user identifier.
[0123] In some embodiments of the present invention, the personalized subject resource is obtained by the server performing personalized adjustment on the subject resource corresponding to the subject identifier according to the user attribute data corresponding to the user identifier.
[0124] As some examples, after receiving a page theme update request, the reverse proxy server may forward it to the server, and the server determines the page theme resource corresponding to the theme identifier based on the theme identifier carried in the page theme update request.
[0125] In some examples, personalized theme resources are obtained by the server after personalized adjustment of the theme resources corresponding to the theme identifier according to the user attribute data corresponding to the user identifier; wherein the user attribute data may be the user's historical operation data; for example, when user 001 switches page theme A to page theme B, the layout or style of the switched page theme B may be adjusted, and these adjustment operations may be used as the historical operation data of user 001; after the user adjusts page theme B, a layout strategy for page theme B may be generated based on the historical operation data.
[0126] After the server determines the page theme resource corresponding to the theme identifier based on the theme identifier carried in the page theme update request, it then determines the corresponding user attribute data based on the user identifier carried in the page theme update request, so as to find the layout strategy for the page theme based on the user attribute data, and determine the user's personalized theme resource, thereby sending the personalized theme resource to the reverse proxy server for caching.
[0127] Step 303: Generate a cache key-value pair according to the subject identifier and the user identifier, and cache the personalized subject resource according to the cache key-value pair.
[0128] In some examples, a key-value pair is an implementation of a mapping in a mathematical concept in a programming language, where the key is used as an index of an element and the value represents the data stored and read; and a cache key-value pair can be used to identify the uniqueness of each cached data, thereby caching personalized theme resources set by the user through the cache key-value pair.
[0129] For example, after the reverse proxy server obtains the personalized theme resource from the server, it can generate a unique cache key-value pair for caching the personalized theme resource based on the theme identifier and user identifier in the page theme update request, and cache the personalized theme resource based on the cache key-value pair. The cache key-value pair can be used to effectively distinguish different users and different page themes, and the cache key-value pair can effectively avoid cache conflicts and improve cache hit rates.
[0130] As some examples, a cache area can be defined in the reverse proxy server for caching personalized theme resources, and rules for generating cache key-value pairs can be defined, such as using the client host name + request URL + user ID + theme ID to generate a cache key-value pair; when a page theme update request is received from any client, a cache key-value pair is generated according to the rules for generating cache key-value pairs, and the obtained personalized theme resources are cached in the corresponding cache area according to the cache key-value pair.
[0131] In some embodiments of the present invention, the method further includes: when it is detected that the theme resource corresponding to the theme identifier changes, obtaining a new personalized theme resource from the server to update the cached personalized theme resource.
[0132] As some examples, when the page content or subject resources change, the notification mechanism in the reverse proxy server will actively refresh the cache area, actively clear expired caches through the data in the API and message queue, and update the latest cache data; when a change is detected in the subject resource corresponding to the subject identifier, the reverse proxy server can send an update request to the server, which can carry the subject identifier, user identifier, and page identifier, so that the server can personalize the subject resource corresponding to the subject identifier according to the user attribute data corresponding to the user identifier, obtain a new personalized subject resource, and send it to the reverse proxy server to update the previously cached personalized subject resource.
[0133] Step 304: Receive a page acquisition request from a target client; wherein the page acquisition request includes a target subject identifier and a target user identifier of the target client.
[0134] In actual applications, when a user enters a website or logs in to a platform through a client or switches pages on the website / platform, the client generates a page acquisition request to send to the reverse proxy server to obtain the page presented to the user by the website or platform.
[0135] For example, when user A is the target user and logs into a website or platform on the client, the client, as the target client of user A, will send a page acquisition request to the reverse proxy server. The page acquisition request includes the target subject identifier and the target user identifier of the target client; the target subject identifier is the subject identifier corresponding to the target subject selected by the target user, and the target user identifier is the target user ID when the target user logs in to the website / platform.
[0136] Step 305: Generate a target cache key-value pair according to the target subject identifier and the target user identifier, and use the target cache key-value pair to determine a target personalized subject resource from the cache.
[0137] After a user successfully logs in to a website or platform through a client and the reverse proxy server receives a page acquisition request, it can generate a target cache key-value pair based on the target subject ID and target user ID according to the rules for generating cache key-value pairs, and use the target cache key-value pair to search for the target personalized subject resource from the cache area of the reverse proxy server.
[0138] Step 306: Generate a target page according to the target personalized subject resource, and send the target page to the target client so as to present the target page on the target client.
[0139] In some embodiments of the present invention, the page acquisition request also includes a page identifier, and generating a target page based on the target personalized subject resource includes: obtaining page content corresponding to the page identifier from the server; and generating the target page based on the target personalized subject resource and the page content.
[0140] As some examples, a page acquisition request includes a page identifier, which may be a page identifier, which refers to an identifier used to uniquely identify an element or location in a web page. In a URL, a page identifier is typically composed of the “#” symbol and the characters following it; for example, #print in http: / / www.xxx.com / xxx.xxx#print is a page identifier.
[0141] After the reverse proxy server receives the page acquisition request from the target client, it can parse the page identifier and then obtain the page content corresponding to the page identifier in the server according to the page identifier; combine the target personalized theme resources found in the cache area of the reverse proxy server and the page content corresponding to the page identifier obtained from the server, render and generate the target page, and send the target page to the target client to present the target page on the target client.
[0142] In some embodiments of the present invention, the method further includes: setting a cache expiration time for the data cached in the reverse proxy server, and updating the cached data when it is detected that the cache time for the data reaches the cache expiration time.
[0143] As some examples, the cache expiration time may be the cache time, such as 7 days; the cache time refers to the length of time that the content is stored in the cache and can be reused.
[0144] After generating the target page based on the target personalized subject resources and page content, the reverse proxy server can also cache the data in the target page according to a pre-set cache strategy, and cache the data to the corresponding cache area according to the target cache key-value pair.
[0145] In some examples, the pre-set cache strategy may include parameters such as cache path, cache name, cache boundary value, and cache time; among which, the cache boundary value refers to certain restrictions and thresholds set in the cache configuration, such as the size of the cache file, the cache expiration time, the cache area size, the number of times the cache is used, etc.
[0146] In actual applications, in order to update the cached data in a timely manner, improve resource utilization and the real-time nature of page content, you can set a cache expiration time for the cached data to ensure that the cached data automatically expires and is updated in a timely manner after a period of time. When it is detected that the cache time of the cached data reaches the cache expiration time, the reverse proxy server can send an update request to the server to update the current cached data in a timely manner.
[0147] In some examples, the data cache expiration time can be set according to the response status code returned by the server; different cache expiration times can also be set according to the type of data in the page content, such as static data and dynamic data.
[0148] As some examples, when the reverse proxy server obtains the page content corresponding to the page identifier from the server according to the page acquisition request, the server can also reply to the reverse proxy server with an HTTP response status code to indicate the processing result of the request; for example, the 200 status code indicates that the request is successful, while the 404 status code indicates that the requested data is not found.
[0149] After the reverse proxy server receives the response status code, it can set different cache expiration times for the acquired data according to different response status codes, so that when the client requests the same data again, the data can be given to the client in time without having to be generated from the server again.
[0150] For example, a longer cache time (such as 200 and 302 redirects) can be set for successful requests and requests with relatively stable data. A 7-day cache time can be set for data with a response status code of 200, so that the data can be reused over a longer period of time without having to request it from the server again. A shorter cache time can be set for temporary requests (404 Not Found). A 5-minute cache time or even no caching can be set for data with a response status code of 404.
[0151] In some embodiments of the present invention, the data cached in the reverse proxy server includes static data and dynamic data, and the cache expiration time of the static data is greater than the cache expiration time of the dynamic data.
[0152] In some embodiments of the present invention, the static data includes personalized theme resources, and the dynamic data includes page content.
[0153] In some examples, static data may be resources that do not change each time a request occurs, such as image files (PNG, GIF, JPG images), font files (WOFF, TTF fonts), video and audio files, etc., and dynamic data may be dynamic web pages (front-end Vue, PHP pages), result web pages generated by user searches, returned personalized recommendation data, etc.
[0154] Among them, since static data rarely changes, a longer cache expiration time can be set; while dynamic data may change frequently due to some factors, a shorter cache expiration time can be set; for example, a cache time of 7 days is set for static data, and a cache time of 10 minutes is set for dynamic data.
[0155] As some examples, the reverse proxy server can be configured to distinguish the type of cached data, so as to set the cache expiration time; for example, it can be distinguished by file extension, header information in the response, request parameters, parameters in the URL path, etc., and static data and dynamic data can be stored in corresponding specific directories; after identification, the cache can be configured to set the corresponding cache time according to the update frequency of the data, and static data can also be compressed to reduce the file size, improve transmission efficiency and data reuse rate. For dynamic data, a shorter cache time can be set to reduce the load on the reverse proxy server and ensure the real-time nature of the data.
[0156] In some embodiments of the present invention, when it is detected that the cache time of the data reaches the cache expiration time, the cached data is updated, including: when it is detected that the cache time of the personalized theme resource reaches the cache expiration time, a new personalized theme resource is obtained from the server to update the cached personalized theme resource.
[0157] As some examples, the reverse proxy server can also detect data in the cache area. When it is detected that the cache duration of personalized theme resources in the cache area reaches the cache expiration duration, a new personalized theme resource can be obtained from the server based on the cache key-value pair to replace the current personalized theme resource with the new personalized theme resource and set the cache expiration duration of the new personalized theme resource.
[0158] In an embodiment of the present invention, a reverse proxy server is set up, and the reverse proxy server receives a page theme update request from any client; wherein the page theme update request includes a theme identifier and a user identifier of the client; according to the theme identifier and the user identifier, a personalized theme resource is obtained from the server; according to the theme identifier and the user identifier, a cache key-value pair is generated, and the personalized theme resource is cached according to the cache key-value pair; a page acquisition request from a target client is received; wherein the page acquisition request includes a target theme identifier and a target user identifier of the target client; according to the target theme identifier and the target user identifier, a target cache key-value pair is generated, and the target personalized theme resource is determined from the cache using the target cache key-value pair; a target page is generated according to the target personalized theme resource, and the target page is sent to the target client to present the target page on the target client; the personalized theme resource of the user is cached by the reverse proxy server, the load on the server is reduced, the response time of the page is improved, and different users and personalized theme resources are distinguished according to the cache key-value pair, thereby avoiding confusion of cached data.
[0159] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0160] Some embodiments of the present invention further provide an electronic device, comprising a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the above method is implemented when the computer program is executed by the processor.
[0161] Some embodiments of the present invention further provide a computer-readable storage medium, on which a computer program is stored, and the computer program implements the above method when executed by a processor.
[0162] Some embodiments of the present invention further provide a computer program product, including a computer program, which implements the above method when executed by a processor.
[0163] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0164] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0165] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0166] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0167] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0168] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0169] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0170] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0171] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the above elements.
[0172] The above is a detailed introduction to a method for processing page theme resources, an electronic device, a medium and a product. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for processing page theme resources, characterized in that: Applied to a reverse proxy server, the reverse proxy server is respectively connected to a server and multiple clients for communication, the method comprising: Receive a page theme update request from any client; wherein the page theme update request includes a theme identifier and a user identifier of the client; Acquire personalized subject resources from the server according to the subject identifier and the user identifier; A cache key-value pair is generated according to the subject identifier and the user identifier, and the personalized subject resource is cached according to the cache key-value pair.
2. The method according to claim 1, characterized in that The personalized subject resource is obtained by the server performing personalized adjustment on the subject resource corresponding to the subject identifier according to the user attribute data corresponding to the user identifier.
3. The method according to claim 1 or 2, characterized in that: Also includes: Receive a page acquisition request from a target client; wherein the page acquisition request includes a target subject identifier and a target user identifier of the target client; Generate a target cache key-value pair according to the target subject identifier and the target user identifier, and use the target cache key-value pair to determine a target personalized subject resource from the cache; A target page is generated according to the target personalized subject resource, and the target page is sent to the target client so as to be presented on the target client.
4. The method according to claim 3, characterized in that: The page acquisition request also includes a page identifier, and generating a target page according to the target personalized subject resource includes: Obtaining the page content corresponding to the page identifier from the server; Generate a target page based on the target personalized subject resources and page content.
5. The method according to claim 4, characterized in that Also includes: A cache expiration time is set for the data cached in the reverse proxy server, and when it is detected that the cache time of the data reaches the cache expiration time, the cached data is updated.
6. The method according to claim 5, characterized in that The data cached in the reverse proxy server includes static data and dynamic data, and the cache expiration time of the static data is longer than the cache expiration time of the dynamic data.
7. The method according to claim 6, characterized in that The static data includes personalized theme resources, and the dynamic data includes page content.
8. The method according to claim 5, characterized in that When it is detected that the cache duration of the data reaches the cache expiration duration, updating the cached data includes: When it is detected that the cache duration of the personalized theme resource reaches the cache expiration duration, a new personalized theme resource is obtained from the server to update the cached personalized theme resource.
9. The method according to claim 1 or 2, characterized in that: Also includes: When it is detected that the theme resource corresponding to the theme identifier changes, a new personalized theme resource is obtained from the server to update the cached personalized theme resource.
10. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the method according to any one of claims 1 to 9 when executed by the processor.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.
12. A computer program product, characterized in that The invention comprises a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 9.
Citation Information
Cited By
Data storage management method and device for multifunctional display support
CN121934686A