Front-end caching method and device based on artificial intelligence and related equipment
By collecting multiple types of data in front-end applications and using artificial intelligence to generate adaptive cache strategies, the problems of insufficient dynamic adaptability, compatibility and security in traditional technologies are solved, and efficient and secure front-end cache management is achieved.
Patent Information
- Application Number
- CN202510354604.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-06-27
AI Technical Summary
Traditional front-end caching technology needs to improve dynamic adaptability, compatibility and security, and there are problems such as cache obsolete, resource redundancy, compatibility differences, performance issues and security threats.
By registering service worker threads in the target front-end application, collecting device information, network environment and user behavior data, using the trained front-end cache policy generation model to generate adaptive cache policies, and by monitoring thread optimization policies, combining privacy and security rules and large language model technology, the cache policy is dynamically adjusted to improve accuracy and security.
It significantly improves the cache hit rate and reduces loading time, achieves the dual improvement of front-end performance and user experience, and at the same time enhances the dynamicity and security of the cache strategy, solving the compatibility and security problems existing in traditional technologies.
Smart Images

Figure CN120216797A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of front-end technologies, and in particular, to a front-end caching method, device, and related equipment based on artificial intelligence. Background Art
[0002] Traditional front-end caching technical solutions can effectively improve front-end caching efficiency and offline support capabilities, but there are still significant defects in actual applications. First, the lack of precision in the cache management strategy leads to cache obsolescence or resource redundancy. For example, in financial applications, a fixed cache strategy may cause delays in updating real-time transaction data, and in medical systems, the failure to invalidate the cache of patient imaging reports in a timely manner may result in diagnostic reference deviations. Second, there are compatibility differences in the parsing and execution of cache strategies by different browser kernels, resulting in inconsistent phenomena when the strategy configuration is executed on multiple devices. For example, an old version of the browser may not correctly identify cache instructions on a financial transaction page, leading to a risk of user information leakage, and the incompatibility of a dedicated browser for medical devices with general cache strategies affects the stability of remote medical services. In addition, the static setting of cache configuration parameters is likely to cause performance problems, such as repeated resource downloads or invalid caches occupying storage space. For example, excessive caching of high-frequency transaction data in a financial front-end application may cause storage overflow, and a single cache strategy in a medical imaging system may result in repeated downloads of high-definition images. At the same time, the design of the offline experience needs to balance resource preloading and storage space limitations. In addition, the openness of the cache strategy may be maliciously exploited to implement a man-in-the-middle attack by forging cache responses, affecting user data security. Summary of the Invention
[0003] The main technical problem to be solved by the embodiments of this application is that traditional front-end caching technologies need to be improved in terms of dynamic adaptability, compatibility, and security.
[0004] To solve the above technical problem, the first technical solution adopted by the embodiments of this application is: to provide a front-end caching method based on artificial intelligence, including: registering a service worker thread in a target front-end application, and collecting device information data, network environment data, and user behavior data of front-end users through the registered service worker thread; generating a first front-end adaptive caching strategy according to the device information data, the network environment data, and the user behavior data through a pre-trained front-end caching strategy generation model; executing the first front-end adaptive caching strategy through the service worker thread, and monitoring preset front-end performance index data using a preset front-end caching strategy monitoring thread to obtain first monitoring result data; generating a strategy optimization script according to the first monitoring result data, and optimizing the first front-end adaptive caching strategy through the strategy optimization script.
[0005] Optionally, the step of generating the first front-end adaptive caching policy by the trained front-end caching policy generation model according to the device information data, the network environment data, and the user behavior data includes: parsing the device information data and the network environment data, and extracting the hardware feature data and network feature data of the device where the target front-end application is located; performing semantic parsing on the user behavior data through a preset large language model to obtain the application scenario feature data of the front-end user; using the hardware feature data, the network feature data, and the application scenario feature data to construct a first multi-dimensional feature vector, and dynamically adjusting the weight coefficients of the features of each dimension of the first multi-dimensional feature vector through an attention mechanism; matching the first multi-dimensional feature vector and the weight coefficients in a preset caching policy rule library, and if the match is successful, obtaining a hit caching policy rule; and generating the corresponding first front-end adaptive caching policy according to the hit caching policy rule and preset caching policy parameters.
[0006] Optionally, the step of generating the corresponding first front-end adaptive caching policy according to the hit caching policy rule and preset caching policy parameters includes: extracting the corresponding policy identifier from the hit caching policy rule, and looking up the policy rule association information according to the policy identifier, where the policy identifier corresponds to the type of the caching policy; screening the target caching policy parameters from a preset caching policy parameter set according to the policy identifier and the type of the caching policy; combining the screened target caching policy parameters and the policy rule association information, and filling the combined policy data into a preset policy template to obtain a to-be-simulated front-end caching policy; verifying the to-be-simulated front-end caching policy through a preset simulation environment, and if the verification is passed, setting the to-be-simulated front-end caching policy as the first front-end adaptive caching policy.
[0007] Optionally, before the step of registering a service worker thread in the target front-end application and collecting the device information data, network environment data, and user behavior data of the front-end user through the registered service worker thread, it further includes: constructing a caching data necessity evaluation model according to a preset privacy and security rule, using the caching data necessity evaluation model to screen the data that can be collected by the target front-end application to obtain pre-collected data and the security processing method of the pre-collected data; setting the security processing method of the pre-collected data of the unique identifier type to perform irreversible hashing processing to obtain an anonymous identifier with a fixed length; setting the security processing method of the pre-collected data that needs to be decrypted to multi-level desensitization and dynamically adjusting the decryption granularity; and sending the collected data after setting the security processing method to the service worker thread.
[0008] Optionally, after the step of monitoring preset front-end performance metric data by using the preset front-end cache policy monitoring thread to obtain first monitoring result data, the following steps are included: extracting the preset front-end performance metric data from the first monitoring result data; if the front-end performance metric data is less than the preset performance metric threshold data, optimizing the privacy and security rules, and using the optimized privacy and security rules to reconstruct a new cache data necessity evaluation model; reprocessing the collectable data through the new cache data necessity evaluation model to obtain new pre-collectable data, so as to increase the data volume of the new pre-collectable data.
[0009] Optionally, the step of generating a policy optimization script according to the first monitoring result data and optimizing the first front-end adaptive cache policy through the policy optimization script includes: extracting the preset front-end performance metric data from the first monitoring result data, and calculating front-end performance derivative feature data according to the front-end performance metric data; comparing the front-end performance metric data and the front-end performance derivative feature data with the policy parameters in the first front-end adaptive cache policy to obtain cache policy parameters to be optimized; processing the cache policy parameters to be optimized according to the corresponding mathematical adjustment model of the cache policy parameters to be optimized to obtain policy optimization script parameters; using a preset script tool to generate the policy optimization script according to the policy optimization script parameters, and optimizing the first front-end adaptive cache policy through the policy optimization script.
[0010] Optionally, after the step of using a preset script tool to generate the policy optimization script according to the policy optimization script parameters, the following steps are further included: simulating the execution of the policy optimization script in a preset isolated sandbox environment, and calculating corresponding optimization improvement metric data according to the execution result data; if the optimization improvement metric data is greater than the preset improvement metric data threshold, executing the policy optimization script and generating a policy optimization log; if the optimization improvement metric data is less than the preset improvement metric data threshold, repeating the steps between extracting the preset front-end performance metric data from the first monitoring result data and calculating the corresponding optimization improvement metric data according to the execution result data until the optimization improvement metric data is greater than the preset improvement metric data threshold, or when the number of repeated executions is greater than the preset repeated execution threshold, stopping the repeated execution and discarding the policy optimization script.
[0011] To solve the above technical problems, the second technical solution adopted in the embodiments of the present application is: to provide a front-end caching device based on artificial intelligence, including: a front-end data acquisition module, configured to register a service worker thread in a target front-end application, and collect device information data, network environment data, and user behavior data of front-end users through the registered service worker thread; a caching policy generation module, configured to generate a first front-end adaptive caching policy according to the device information data, the network environment data, and the user behavior data through a trained front-end caching policy generation model; a monitoring result data module, configured to execute the first front-end adaptive caching policy through the service worker thread, and monitor preset front-end performance index data using a preset front-end caching policy monitoring thread to obtain first monitoring result data; a caching policy optimization module, configured to generate a policy optimization script according to the first monitoring result data, and optimize the first front-end adaptive caching policy through the policy optimization script.
[0012] To solve the above technical problems, the third technical solution adopted in the embodiments of the present application is: to provide an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the front-end caching method based on artificial intelligence as described above.
[0013] To solve the above technical problems, the fourth technical solution adopted in the embodiments of the present application is: to provide a non-volatile computer-readable storage medium, the non-volatile computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by an electronic device, the electronic device is enabled to execute the front-end caching method based on artificial intelligence as described above.
[0014] Different from the related art, the present application collects multiple types of data through service worker threads, processes them according to privacy and security rules, solves data redundancy and privacy problems, generates multi-dimensional feature vectors with the help of technologies such as large language models, dynamically adjusts weights, adapts to different scenarios, and improves the accuracy of caching policies. Through rule matching, parameter screening, and simulation verification, the stability of the policy is ensured. Combining monitoring indicators and derivative feature analysis to build a closed-loop optimization, it improves the caching hit rate and reduces the loading time in financial and medical scenarios, achieving a double improvement in front-end performance and user experience. Description of the Drawings
[0015] One or more embodiments are exemplarily illustrated by corresponding drawings. These exemplary illustrations do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings are represented as similar elements, unless otherwise stated, and the drawings in the figures do not constitute a proportional limitation.
[0016] Figure 1 It is a schematic diagram of the operating environment of the front-end caching method based on artificial intelligence provided by an embodiment of the present application.
[0017] Figure 2 It is a schematic diagram of the execution process of the front-end caching method based on artificial intelligence provided by an embodiment of the present application.
[0018] Figure 3 It is a schematic diagram of the execution process of setting the collected data in the front-end caching method based on artificial intelligence provided by an embodiment of the present application.
[0019] Figure 4 It is a schematic diagram of the execution process of generating a front-end adaptive caching policy in the front-end caching method based on artificial intelligence provided by an embodiment of the present application.
[0020] Figure 5 It is a schematic diagram of the system structure of the front-end caching device based on artificial intelligence provided by an embodiment of the present application.
[0021] Figure 6 It is a schematic diagram of the hardware structure of an electronic device for executing the front-end caching method based on artificial intelligence provided by an embodiment of the present application. Detailed implementation manners
[0022] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0023] It should be noted that if there is no conflict, the various features in the embodiments of the present application can be combined with each other, and all are within the protection scope of the present application. In addition, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order from the module division in the device schematic diagram or the flowchart.
[0024] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not used to limit this application. The term "and / or" used in this specification includes any and all combinations of one or more of the related listed items.
[0025] For ease of understanding of this embodiment, first, a front-end caching method based on artificial intelligence disclosed in the embodiments of the present application will be introduced in detail. Please refer to Figure 1 , Figure 1It is a schematic diagram of the operating environment of the front-end caching method based on artificial intelligence provided by an embodiment of the present application. As Figure 1 shown, the execution subject of the front-end caching method based on artificial intelligence provided by an embodiment of the present application is generally an electronic device with certain computing capabilities, such as a computer device. In some possible implementation manners, the front-end caching method based on artificial intelligence can be implemented by a processor calling computer-readable instructions stored in a memory. Among them, Figure 1 the computer device in Figure 1 can be a server. The server can be an independent server or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms. It can be understood that
[0026] Please continue to refer to Figure 2 , Figure 2 which is a schematic diagram of the execution process of the front-end caching method based on artificial intelligence provided by an embodiment of the present application. As Figure 2 shown, it includes the following steps:
[0027] S1. Register a service worker in the target front-end application, and collect device information data, network environment data, and user behavior data of the front-end user through the registered service worker.
[0028] Among them, the service worker is an independent thread running in the background of the browser. By intercepting network requests and caching resource data, it realizes functions such as offline access, dynamic cache policy management, and push notifications. It is independent of the web page main thread, can globally control the loading behavior of front-end resources, improve application performance and offline experience, and at the same time support event-driven life cycle management (such as installation, activation, update). User behavior data is some historical operations of the user in the current front-end application. For example, in the front-end application in the financial field, the user login frequency (multiple times a day, several times a week, etc.), the number of times of viewing the financial product details page, and the frequency and time of trading operations (buying and selling stocks, etc.). For example, users with frequent transactions may need real-time updated trading data caching, while users who view occasionally can cache comprehensive data within a certain period of time.
[0029] As an optional implementation manner, please continue to refer to Figure 3 , Figure 3 which is a schematic diagram of the execution process of setting the collected data in the front-end caching method based on artificial intelligence provided by an embodiment of the present application.Figure 3 As shown in the figure, it includes the following steps S11 to S14.
[0030] S11. Construct a cache data necessity evaluation model according to the preset privacy and security rules, use the cache data necessity evaluation model to screen the collectible data of the target front-end application, obtain the pre-collected data, and the security processing method of the pre-collected data.
[0031] For example, in a financial front-end application, privacy and security rules are formulated, stipulating that the collected data is only used for financial services and sensitive information is strictly protected. When constructing a cache data necessity evaluation model, three evaluation dimensions of data sensitivity, necessity, and usage purpose are determined, and weights of 0.5, 0.3, and 0.2 are assigned respectively. For example, a bank card number belongs to high-sensitivity data and cannot be collected without the explicit authorization of the user; transaction records are high-necessity data and can be collected and stored in encrypted form using AES after authorization; while data of low necessity such as browser type needs to be comprehensively considered to decide whether to collect. For medium-sensitivity data such as mobile phone numbers that can be collected, multi-level desensitization processing is adopted. Another example is in a medical front-end application, where the privacy and security rules require that the data is only used for medical-related purposes and the transmission needs to ensure security. The model evaluation dimensions include data sensitivity, necessity, and usage purpose, with weights of 0.6, 0.3, and 0.1 respectively. High-sensitivity and high-necessity data such as medical records are collected after the authorization of the patient and stored in encrypted form using RSA; medium-sensitivity data such as patient contact information is partially desensitized after collection; low-sensitivity and high-necessity data such as device usage duration can be stored routinely, while low-necessity data such as screen brightness settings is collected with caution.
[0032] S12. Set the security processing method of the pre-collected data of the unique identifier type to perform irreversible hashing processing to obtain an anonymous identifier of a fixed length.
[0033] S13. Set the security processing method of the pre-collected data that needs to be decrypted to multi-level desensitization and dynamically adjust the decryption granularity.
[0034] Among them, multi-level desensitization refers to adopting different intensities of desensitization methods such as character replacement, truncation, and masking according to the data sensitivity level. Dynamically adjusting the decryption granularity means flexibly controlling the desensitization fineness according to the data usage scenario, user permissions, and real-time status. The combination of the two can maximize the data availability while protecting privacy. For example, in a financial scenario, deep desensitization is implemented for high-sensitivity transaction data, while only mild processing is done for low-sensitivity device information, which not only meets the compliance requirements but also ensures the business analysis needs.
[0035] S14. Send the collected data after setting the security processing method to the service worker thread.
[0036] Among them, through the above steps S11 to S14, data that can be collected can be accurately screened according to privacy and security rules, pre-collected data can be obtained, and its security processing method can be determined. Irreversible hashing processing is performed on unique identifier type data, multi-level desensitization is performed on data that needs to be decrypted, and the granularity is dynamically adjusted, ensuring the privacy and security of user data. At the same time, the data after security processing is transmitted to the service working thread, providing a reliable and secure data basis for the formulation of subsequent front-end adaptive caching strategies, avoiding potential risks caused by data security problems, improving the overall security of front-end applications in the process of data collection and use, and optimizing the data utilization efficiency.
[0037] S2. Generate a first front-end adaptive caching strategy through the trained front-end caching strategy generation model according to device information data, network environment data, and user behavior data.
[0038] As an optional implementation manner, please continue to refer to Figure 4 , Figure 4 which is a schematic execution flowchart of generating a front-end adaptive caching strategy in the front-end caching method based on artificial intelligence provided by the embodiments of the present application. As shown in Figure 4 , it includes the following steps S21 to S25.
[0039] S21. Analyze the device information data and the network environment data, and extract the hardware feature data and network feature data of the device where the target front-end application is located.
[0040] Among them, in the front-end application project, hardware feature data and network feature data are important data types parsed from device information data and network environment data. Hardware feature data covers the physical attributes and performance indicators of the device, such as the model of the device (such as iPhone 14 Pro, Huawei P60), the type of operating system (iOS, Android, Windows) and its version number, screen resolution (2K, 4K), memory size (8GB, 16GB), CPU model (Intel Core i7), etc. These data reflect the basic capabilities and operating environment of the device. Network feature data reflects the network status of the device, such as network type (4G, 5G, Wi-Fi), network bandwidth (10 Mbps, 100 Mbps), network latency (20 ms, 50 ms), IP address location (Beijing, Shanghai), etc. They play a key role in the resource loading speed and data transmission stability of front-end applications.
[0041] S22. Perform semantic parsing on the user behavior data through a preset large language model to obtain the application scenario feature data of the front-end user.
[0042] Among them, in financial front-end applications, if a user frequently operates the transfer function and searches for the keyword "cross-border remittance" multiple times, the large language model can extract the scenario features of "cross-border transaction demand" through semantic analysis of the user behavior data, including transaction amount, frequency, destination country, etc.; in medical front-end applications, if a user continuously views CT image reports and asks about the "nature of pulmonary nodules" multiple times, the model can identify the scenario features of "imaging diagnosis consultation", covering key information such as lesion type, examination date, patient age, etc., so as to provide accurate scenario-based basis for the caching strategy.
[0043] S23. Construct a first multi-dimensional feature vector using the hardware feature data, the network feature data, and the application scenario feature data, and dynamically adjust the weight coefficients of the features of each dimension of the first multi-dimensional feature vector through an attention mechanism.
[0044] Among them, setting dynamic weight coefficients when constructing the first multi-dimensional feature vector can intelligently allocate the importance of hardware features, network features, and application scenario features through the attention mechanism, significantly improving the accuracy and adaptability of the front-end caching strategy. For example, in a medical imaging system, when the user is in an offline scenario (the weight of the scenario feature is increased) and the device storage space is insufficient (the weight of the hardware feature is adjusted), the system will preferentially cache low-resolution images to balance the storage limit; in a financial transaction scenario, if a high network latency is detected (the weight of the network feature is enhanced), the preloading priority of key transaction pages will be dynamically increased to ensure smooth interaction in a weak network environment. This dynamic weight mechanism can avoid the rigidity problem of traditional static strategies, flexibly optimize resource allocation according to real-time scenario requirements, not only improve the cache hit rate but also reduce redundant storage, and at the same time ensure data security by strengthening the feature weights of sensitive scenarios, such as the caching strategy of preferentially encrypting and processing patient privacy data in a medical diagnosis scenario.
[0045] S24. Match the first multi-dimensional feature vector and the weight coefficients in a preset caching strategy rule library. If the match is successful, obtain the hit caching strategy rule.
[0046] S25. Generate the corresponding first front-end adaptive caching strategy according to the hit caching strategy rule and the preset caching strategy parameters.
[0047] Among them, through the above steps S21 to S25, the cache hit rate is improved, redundant storage is reduced, data security in sensitive scenarios is guaranteed, and the performance stability and user experience of the front-end application are enhanced.
[0048] As another alternative implementation manner, the above step S25 may specifically include the following sub-steps S251 to S254.
[0049] S251. Extract the corresponding policy identifier from the hit cache policy rules, and look up the policy rule association information according to the policy identifier, where the policy identifier corresponds to the type of cache policy.
[0050] S252. Filter out the target cache policy parameters from the preset cache policy parameter set according to the policy identifier and the type of cache policy.
[0051] For example, in a financial scenario, if the hit policy identifier is "real-time transaction cache", then select parameters such as max-age = 60 (minute-level update) and stale-while-revalidate = 30 (allow a 30-second transition period after cache expiration) from the parameter set according to the policy type (high-frequency and low-latency requirements) to ensure timely refresh of transaction data; in a medical scenario, if the policy identifier is "imaging report cache", then filter parameters such as max-size = 5GB (storage space limit) and encrypted = true (forced encryption) according to the type (large file storage requirements) to balance storage efficiency and patient privacy protection.
[0052] S253. Combine the filtered target cache policy parameters and the policy rule association information, and fill the combined policy data into the preset policy template to obtain the to-be-simulated front-end cache policy.
[0053] S254. Verify the to-be-simulated front-end cache policy through the preset simulation environment. If the verification passes, set the to-be-simulated front-end cache policy as the first front-end adaptive cache policy.
[0054] Among them, steps S251 to S254 achieve the precise adaptation and security control of the cache policy through the modular management of the policy identifier, dynamic parameter screening, templated policy generation, and simulation verification mechanism. Specifically, the extraction of the policy identifier and the query of the association information ensure the rapid positioning and unified management of cache policies in different scenarios. For example, different policy identifiers are used to distinguish financial high-frequency transactions and medical image storage; parameter screening can dynamically match the optimal parameter combination according to the policy type. For example, minute-level update parameters are selected in the financial scenario to ensure data timeliness, and encrypted storage parameters are selected in the medical scenario to protect privacy; template filling improves development efficiency through a standardized policy structure, and at the same time, the combination and reuse of policy rules and parameters reduce maintenance costs; simulation verification ensures the effectiveness and security of the policy in complex scenarios through means such as stress testing and compatibility testing before deployment. For example, verify the response speed of the financial policy in high-concurrency transactions or the stability of the medical policy during network fluctuations, and finally achieve the dynamic optimization and risk control of the cache policy.
[0055] S3. Execute the first front - end adaptive caching policy through the service worker thread, and use a preset front - end caching policy monitoring thread to monitor preset front - end performance metric data to obtain the first monitoring result data.
[0056] Among them, the preset monitoring thread continuously collects front - end performance metric data (such as cache hit rate, resource loading time, memory occupancy rate, page response time, etc.) to form the first monitoring result data. For example, in the financial scenario, the monitoring thread will count the cache hit times of transaction data to verify the effectiveness of the policy; in the medical scenario, the loading speed of CT images is monitored to evaluate the improvement of the caching policy on the diagnosis and treatment efficiency. Through the closed - loop mechanism of policy execution and real - time monitoring, this step can not only improve the page loading speed and user experience, but also provide data support for subsequent policy optimization to ensure that the caching policy always adapts to the dynamic changes of device performance, network environment and user behavior.
[0057] As an optional implementation method, after the above step S3, the above privacy - security rules and the cache data necessity evaluation model can also be adjusted according to the monitoring result data. If the granularity setting of the privacy - security rules is inappropriate, it may lead to less front - end collected data, and thus the optimization degree that the generated first front - end adaptive caching policy can achieve is limited. At this time, the above - mentioned factor security rules and the cache data necessity evaluation model can be adjusted to obtain more front - end collected data to improve the optimization effect of the front - end adaptive caching policy. Specifically, extract the preset front - end performance metric data from the first monitoring result data. If the front - end performance metric data is less than the preset performance metric threshold data, optimize the privacy - security rules, and use the optimized privacy - security rules to reconstruct a new cache data necessity evaluation model. Finally, re - process the collectable data through the new cache data necessity evaluation model to obtain new pre - collectable data to increase the data volume of the new pre - collectable data. By dynamically adjusting the privacy rules and data models, increasing the amount of effective data, improving the accuracy of the caching policy, optimizing performance and balancing privacy and efficiency, the system adaptability is enhanced.
[0058] S4. Generate a policy optimization script according to the first monitoring result data, and optimize the first front - end adaptive caching policy through the policy optimization script.
[0059] As an optional implementation method, the above step S4 can specifically include the following steps S41 to S44.
[0060] S41. Extract the preset front - end performance metric data from the first monitoring result data, and calculate the front - end performance derivative feature data according to the front - end performance metric data.
[0061] Among them, it is information with additional value obtained through specific calculations and in-depth analysis based on preset front-end performance metric data. The preset front-end performance metric data are basic data that can be directly measured or obtained, such as cache hit rate, resource loading time, memory occupancy, etc. The derived feature data is a further exploration of these basic metrics. For example, by calculating the standard deviation of the resource loading time, a derived feature data reflecting the stability of the resource loading time can be obtained; analyzing the change trend of the cache hit rate over a period of time allows us to understand whether the cache hit rate is increasing, decreasing, or remaining stable. In the financial application scenario, the derived feature data can reveal the variation law of the cache hit rate with trading peaks and troughs; in the medical application, it can reflect the correlation between the cache hit rate of image reports and the patient access volume at different time periods.
[0062] S42. Compare the front-end performance metric data and the front-end performance derived feature data with the policy parameters in the first front-end adaptive caching policy to obtain the cache policy parameters to be optimized.
[0063] For example, in a financial transaction front-end application, the cache maximum survival time (max-age) parameter set by the first front-end adaptive caching policy is 300 seconds, that is, the cached data expires after 300 seconds. After running for a period of time, the collected front-end performance metric data shows that the actual cache hit rate is relatively low, and the front-end performance derived feature data indicates that the cache hit rate drops rapidly over time. Through comparison, it is found that the current max-age parameter setting may be too long, resulting in outdated cached data and thus affecting the cache hit rate. Therefore, the max-age parameter is determined as the cache policy parameter to be optimized.
[0064] S43. Process the cache policy parameters to be optimized according to the corresponding mathematical adjustment model of the cache policy parameters to be optimized to obtain the policy optimization script parameters.
[0065] For example, in a medical imaging front-end application, the mathematical adjustment model adjusts the cache update frequency parameter according to factors such as the generation speed of image data and the average time interval for doctors to view images. Suppose the model calculates that adjusting the cache update frequency to once every 6 hours can significantly improve the loading speed of image resources and the doctor's usage experience. Then the parameter of updating once every 6 hours becomes the policy optimization script parameter for subsequent cache policy optimization.
[0066] S44. Use the preset script tool to generate a policy optimization script according to the policy optimization script parameters, and optimize the first front-end adaptive caching policy through the policy optimization script.
[0067] Among them, for steps S41 to S44 above, starting from the first monitoring result data, by extracting the front-end performance index data and calculating the derivative feature data, the front-end performance status can be comprehensively and deeply grasped. Then, by comparing these data with the original policy parameters, the parts of the policy that do not conform to the actual performance can be accurately found, and the cache policy parameters to be optimized can be determined. Subsequently, these parameters are scientifically processed by means of a mathematical adjustment model to obtain the optimized parameters that can be directly applied to the script. Finally, a policy optimization script is generated based on these parameters using a preset script tool to achieve the dynamic optimization of the first front-end adaptive cache policy. The front-end cache policy can be dynamically adjusted according to the actual running situation, improving the cache hit rate, reducing the resource loading time, ensuring the stable operation of the front-end system, and providing users with a smooth and efficient front-end application experience.
[0068] As another alternative implementation, after step S44 above, the policy optimization script can also be verified in a simulation environment. Specifically, the execution of the policy optimization script is simulated in a preset isolated sandbox environment, and the corresponding optimized improvement index data is calculated based on the execution result data. If the optimized improvement index data is greater than the preset improvement index data threshold, the policy optimization script is executed, and a policy optimization log is generated. If the optimized improvement index data is less than the preset improvement index data threshold, the steps between extracting the preset front-end performance index data from the first monitoring result data and calculating the corresponding optimized improvement index data based on the execution result data are repeatedly executed until the optimized improvement index data is greater than the preset improvement index data threshold, or when the number of repeated executions is greater than the preset repeated execution threshold, the repeated execution is stopped, and the policy optimization script is discarded. Verifying the policy optimization script in a simulation environment and deciding whether to execute it through index comparison can ensure the optimization effect, avoid ineffective adjustments, ensure the continuous optimization of the front-end cache policy, and effectively improve the effectiveness and stability of the front-end cache policy.
[0069] The front - end caching method based on artificial intelligence provided by the embodiments of this application collects device information, network environment, and user behavior data in real - time through service worker threads, constructs a necessity evaluation model in combination with privacy and security rules to screen the data to be collected and perform security processing such as hash anonymization and multi - level desensitization; uses a large - language model to parse user behavior to generate scenario features, fuses hardware and network features to construct a multi - dimensional feature vector, dynamically adjusts the weights through the attention mechanism, and then matches the policy rule library to generate an adaptive caching policy including parameter screening, template filling, and simulation verification; collects performance metrics such as cache hit rate and loading time through a monitoring thread, calculates derivative features and compares policy parameters, and generates an optimization script in combination with a mathematical model, finally forming a closed - loop system of "data collection - policy generation - execution monitoring - dynamic optimization". This method significantly improves the cache hit rate and resource utilization through multi - dimensional feature fusion, scenario - based policy adaptation, and continuous optimization mechanisms, realizes precise cache management in scenarios such as high - frequency updates in financial transactions and secure storage of medical images, and at the same time ensures the security and effectiveness of policy adjustment through sandbox verification, balancing the requirements of performance optimization and privacy protection.
[0070] Please continue to refer to Figure 5 , Figure 5 FIG. is a schematic structural diagram of a system of a front - end caching device based on artificial intelligence provided by the embodiments of this application. As Figure 5 shown, the front - end caching device 50 based on artificial intelligence includes: a front - end data collection module 51, a cache policy generation module 52, a monitoring result data module 53, and a cache policy optimization module 54.
[0071] The front - end data collection module 51 is specifically configured to register a service worker thread in a target front - end application, and collect device information data, network environment data, and user behavior data of front - end users through the registered service worker thread.
[0072] The cache policy generation module 52 is specifically configured to generate a first front - end adaptive caching policy according to the device information data, network environment data, and user behavior data through a trained front - end caching policy generation model.
[0073] The monitoring result data module 53 is specifically configured to execute the first front - end adaptive caching policy through the service worker thread, and monitor preset front - end performance metric data using a preset front - end caching policy monitoring thread to obtain first monitoring result data.
[0074] The cache policy optimization module 54 is specifically configured to generate a policy optimization script according to the first monitoring result data, and optimize the first front - end adaptive caching policy through the policy optimization script.
[0075] As an alternative implementation, the cache policy generation module 52 is specifically configured to parse the device information data and network environment data, extract the hardware feature data and network feature data of the device where the target front-end application is located; perform semantic parsing on the user behavior data through a preset large language model to obtain the application scenario feature data of the front-end user; use the hardware feature data, network feature data, and application scenario feature data to construct a first multi-dimensional feature vector, and dynamically adjust the weight coefficients of the features of each dimension of the first multi-dimensional feature vector through an attention mechanism; match the first multi-dimensional feature vector and the weight coefficients in a preset cache policy rule library, and if the match is successful, obtain the hit cache policy rule; generate a corresponding first front-end adaptive cache policy according to the hit cache policy rule and the preset cache policy parameters.
[0076] As an alternative implementation, the cache policy generation module 52 is further specifically configured to extract the corresponding policy identifier from the hit cache policy rule, and look up the policy rule association information according to the policy identifier, where the policy identifier corresponds to the type of the cache policy; screen and obtain the target cache policy parameters from a preset cache policy parameter set according to the policy identifier and the type of the cache policy; combine the screened target cache policy parameters and the policy rule association information, and fill the combined policy data into a preset policy template to obtain the to-be-simulated front-end cache policy; verify the to-be-simulated front-end cache policy through a preset simulation environment, and if the verification is passed, set the to-be-simulated front-end cache policy as the first front-end adaptive cache policy.
[0077] As an alternative implementation, the artificial intelligence-based front-end cache device 50 further includes a data collection security module, and the data collection security module is specifically configured to construct a cache data necessity evaluation model according to a preset privacy and security rule, and use the cache data necessity evaluation model to screen the collectable data of the target front-end application to obtain the pre-collected data and the security processing method of the pre-collected data; set the security processing method of the pre-collected data of the unique identifier type to perform irreversible hashing processing to obtain an anonymous identifier with a fixed length; set the security processing method of the pre-collected data that needs to be decrypted to multi-level desensitization and dynamically adjust the decryption granularity; send the collected data after setting the security processing method to the service working thread.
[0078] As an alternative implementation, the data collection security module is further specifically configured to extract the preset front-end performance index data from the first monitoring result data; if the front-end performance index data is less than the preset performance index threshold data, optimize the privacy and security rule, and use the optimized privacy and security rule to reconstruct a new cache data necessity evaluation model; reprocess the collectable data through the new cache data necessity evaluation model to obtain new pre-collected data, so as to increase the data volume of the new pre-collected data.
[0079] As an alternative implementation, the cache policy optimization module 54 is specifically configured to extract preset front-end performance index data from the first monitoring result data, calculate front-end performance derivative feature data based on the front-end performance index data; compare the front-end performance index data and the front-end performance derivative feature data with the policy parameters in the first front-end adaptive cache policy to obtain cache policy parameters to be optimized; process the cache policy parameters to be optimized according to the corresponding mathematical adjustment model of the cache policy parameters to be optimized to obtain policy optimization script parameters; use a preset script tool to generate a policy optimization script based on the policy optimization script parameters, and optimize the first front-end adaptive cache policy through the policy optimization script.
[0080] As an alternative implementation, the cache policy optimization module 54 is further specifically configured to simulate the execution of the policy optimization script in a preset isolated sandbox environment, calculate corresponding optimization improvement index data according to the execution result data; if the optimization improvement index data is greater than a preset improvement index data threshold, execute the policy optimization script and generate a policy optimization log; if the optimization improvement index data is less than the preset improvement index data threshold, repeat the steps from extracting the preset front-end performance index data from the first monitoring result data to calculating the corresponding optimization improvement index data according to the execution result data until the optimization improvement index data is greater than the preset improvement index data threshold, or when the number of repeated executions is greater than a preset repeated execution threshold, stop repeating the execution and discard the policy optimization script.
[0081] It should be noted that the above front-end caching device based on artificial intelligence can execute the front-end caching method based on artificial intelligence provided in the embodiments of the present application, and has corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in the embodiments of the front-end caching device based on artificial intelligence can be referred to the front-end caching method based on artificial intelligence provided in the embodiments of the present application.
[0082] Figure 6 is a schematic hardware structure diagram of an electronic device 600 for executing the front-end caching method based on artificial intelligence provided in the embodiments of the present application, as Figure 6 shown. The electronic device 600 includes:
[0083] One or more processors 610 and a memory 620, Figure 6 Taking one processor 610 as an example in
[0084] The processor 610 and the memory 620 can be connected through a bus or other means, Figure 6 Taking connection through a bus as an example in
[0085] The memory 620, being a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules, such as the program instructions / modules corresponding to the artificial-intelligence-based front-end caching method in the embodiments of the present application. The processor 610 executes various functional applications and data processing of the server by running the non-volatile software programs, instructions, and modules stored in the memory 620, thereby implementing the artificial-intelligence-based front-end caching method in the above method embodiments.
[0086] The memory 620 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store data created according to the use of the artificial-intelligence-based front-end caching device, etc. In addition, the memory 620 may include high-speed random-access memory and may also include non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 620 may optionally include a memory remotely disposed relative to the processor 610, and these remote memories can be connected to the artificial-intelligence-based front-end caching device through a network. Examples of the above network include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.
[0087] The one or more modules are stored in the memory 620 and, when executed by the one or more processors 610, execute the artificial-intelligence-based front-end caching method in any of the above method embodiments. For example, execute the method steps S1 to S4 described above Figure 2 in, Figure 3 the method steps S21 to S25 in, Figure 4 the method steps S11 to S14 in, and implement Figure 4 the functions of the modules 51 - 54 in.
[0088] The above product can execute the method provided in the embodiments of the present application and has corresponding functional modules and beneficial effects for executing the method. Technical details not described in detail in this embodiment can be found in the method provided in the embodiments of the present application.
[0089] The embodiments of the present application provide a non-volatile computer-readable storage medium storing computer-executable instructions, which when executed by one or more processors, such as Figure 6 one of the processors 610 in, can enable the above one or more processors to execute the artificial-intelligence-based front-end caching method in any of the above method embodiments. For example, execute the method steps S1 to S4 described above Figure 2 in, Figure 3The method steps S21 to S25 in Figure 4 The method steps S11 to S14 in Figure 4 realize the functions of modules 51 - 54 in
[0090] An embodiment of the present application provides a computer program product. The computer program product includes a computer program stored on a non - volatile computer - readable storage medium. The computer program includes program instructions. When the program instructions are executed by the electronic device, the electronic device can execute the artificial - intelligence - based front - end caching method in any of the above - mentioned method embodiments. For example, execute the method steps S1 to S4 described above in Figure 2 The method steps S1 to S4 in Figure 3 The method steps S21 to S25 in Figure 4 The method steps S11 to S14 in Figure 4 realize the functions of modules 51 - 54 in
[0091] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0092] Through the description of the above - mentioned implementation manners, those of ordinary skill in the art can clearly understand that each implementation manner can be realized by means of software plus a general - purpose hardware platform, and of course, it can also be realized by hardware. Those of ordinary skill in the art can understand that all or part of the processes in the above - mentioned method embodiments can be completed by instructing relevant hardware through a computer program. The program can be stored in a computer - readable storage medium. When the program is executed, it can include the processes of the above - mentioned method embodiments. Among them, the storage medium can be a magnetic disk, an optical disk, a read - only memory (ROM), or a random access memory (RAM), etc.
[0093] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them; under the idea of the present application, the technical features in the above embodiments or different embodiments can also be combined, and the steps can be implemented in any order, and there are many other variations in different aspects of the present application as described above. For the sake of brevity, they are not provided in detail; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A front-end caching method based on artificial intelligence, characterized in that: include: Register a service worker thread in the target front-end application, and collect device information data, network environment data, and user behavior data of the front-end user through the registered service worker thread; Generate a first front-end adaptive cache strategy according to the device information data, the network environment data and the user behavior data through the trained front-end cache strategy generation model; Executing the first front-end adaptive cache strategy through the service worker thread, and using a preset front-end cache strategy monitoring thread to monitor preset front-end performance indicator data, to obtain first monitoring result data; A policy optimization script is generated according to the first monitoring result data, and the first front-end adaptive cache policy is optimized by the policy optimization script.
2. The front-end caching method based on artificial intelligence according to claim 1, characterized in that: The step of generating a first front-end adaptive cache strategy according to the device information data, the network environment data and the user behavior data by using the trained front-end cache strategy generation model includes: Parsing the device information data and the network environment data, and extracting the hardware feature data and network feature data of the device where the target front-end application is located; Perform semantic analysis on the user behavior data through a preset large language model to obtain application scenario feature data of the front-end user; Constructing a first multidimensional feature vector using the hardware feature data, the network feature data, and the application scenario feature data, and dynamically adjusting the weight coefficients of each dimensional feature of the first multidimensional feature vector through an attention mechanism; Matching is performed in a preset cache strategy rule library according to the first multidimensional feature vector and the weight coefficient, and if the match is successful, a cache strategy rule is hit; According to the hit cache policy rule and the preset cache policy parameters, the corresponding first front-end adaptive cache policy is generated.
3. The front-end caching method based on artificial intelligence according to claim 2, characterized in that: The step of generating the corresponding first front-end adaptive cache strategy according to the hit cache strategy rule and the preset cache strategy parameters includes: Extracting a corresponding policy identifier from the hit cache policy rule, and searching for policy rule association information according to the policy identifier, wherein the policy identifier corresponds to a type of cache policy; According to the policy identifier and the type of the cache policy, a target cache policy parameter is obtained by screening from a preset cache policy parameter set; The target cache policy parameters and the policy rule association information obtained by combining the screening are filled into a preset policy template with the combined policy data to obtain the front-end cache policy to be simulated; The front-end cache strategy to be simulated is verified through a preset simulation environment. If the verification passes, the front-end cache strategy to be simulated is set as the first front-end adaptive cache strategy.
4. The front-end caching method based on artificial intelligence according to claim 1, characterized in that: Before the step of registering a service worker thread in the target front-end application and collecting device information data, network environment data, and user behavior data of the front-end user through the registered service worker thread, the step further includes: Constructing a cache data necessity assessment model according to preset privacy and security rules, using the cache data necessity assessment model to screen the collectible data of the target front-end application, obtaining pre-collected data, and a secure processing method for the pre-collected data; The secure processing method of the pre-collected data of the unique identification type is to perform irreversible hash processing to obtain an anonymous identifier of a fixed length; Setting the security processing method of the pre-collected data to be decrypted to multi-level desensitization, and dynamically adjusting the decryption granularity; The collected data after setting the security processing mode is sent to the service working thread.
5. The front-end caching method based on artificial intelligence according to claim 4 is characterized in that: After the step of using the preset front-end cache strategy monitoring thread to monitor the preset front-end performance indicator data and obtaining the first monitoring result data, the method further includes: Extracting the preset front-end performance indicator data from the first monitoring result data; If the front-end performance indicator data is less than the preset performance indicator threshold data, the privacy security rules are optimized, and a new cache data necessity evaluation model is rebuilt using the optimized privacy security rules; The collectible data is reprocessed by using the new cache data necessity evaluation model to obtain new pre-collected data, so as to increase the data volume of the new pre-collected data.
6. The front-end caching method based on artificial intelligence according to claim 1, characterized in that: Generating a strategy optimization script according to the first monitoring result data, and optimizing the first front-end adaptive cache strategy by using the strategy optimization script, includes: Extracting the preset front-end performance indicator data from the first monitoring result data, and calculating the front-end performance derived characteristic data according to the front-end performance indicator data; Comparing the front-end performance indicator data and the front-end performance derived characteristic data with the policy parameters in the first front-end adaptive cache policy to obtain the cache policy parameters to be optimized; Processing the cache policy parameters to be optimized according to the mathematical adjustment model corresponding to the cache policy parameters to be optimized to obtain policy optimization script parameters; The policy optimization script is generated according to the policy optimization script parameters using a preset script tool, and the first front-end adaptive cache policy is optimized by the policy optimization script.
7. The front-end caching method based on artificial intelligence according to claim 6, characterized in that: After the step of using a preset script tool to generate the strategy optimization script according to the strategy optimization script parameters, the method further includes: Simulate the execution of the strategy optimization script in a preset isolated sandbox environment, and calculate the corresponding optimization improvement index data based on the execution result data; If the optimization improvement index data is greater than the preset improvement index data threshold, the strategy optimization script is executed and a strategy optimization log is generated; If the optimization improvement index data is less than the preset improvement index data threshold, the steps from extracting the preset front-end performance index data from the first monitoring result data to calculating the corresponding optimization improvement index data according to the execution result data are repeatedly executed until the optimization improvement index data is greater than the preset improvement index data threshold, or when the number of repeated executions is greater than the preset repetition number threshold, the repeated execution is stopped and the strategy optimization script is discarded.
8. A front-end cache device based on artificial intelligence, characterized in that: include: The front-end data collection module is used to register a service worker thread in the target front-end application and collect the device information data, network environment data and user behavior data of the front-end user through the registered service worker thread; A cache strategy generation module, configured to generate a first front-end adaptive cache strategy according to the device information data, the network environment data and the user behavior data through a trained front-end cache strategy generation model; A monitoring result data module, used to execute the first front-end adaptive cache strategy through the service worker thread, and use a preset front-end cache strategy monitoring thread to monitor preset front-end performance indicator data to obtain first monitoring result data; A cache strategy optimization module is used to generate a strategy optimization script according to the first monitoring result data, and optimize the first front-end adaptive cache strategy through the strategy optimization script.
9. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the artificial intelligence-based front-end caching method described in any one of claims 1-7.
10. A non-volatile computer-readable storage medium, characterized in that: The non-volatile computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are executed by an electronic device, the electronic device executes the artificial intelligence-based front-end caching method described in any one of claims 1-7.
Citation Information
Cited By
File caching performance improving method and system based on distributed storage
CN121722325A