A project resource loading method, device and equipment and storage medium
Through the server-side classification and risk scoring mechanism, the problems of resource redundancy and uncontrollable updates in the parallel deployment of multiple projects are solved, efficient and controllable resource loading and updates are achieved, and system stability and user experience are improved.
Patent Information
- Application Number
- CN202511041351.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-28
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-07-28
AI Technical Summary
Existing technologies suffer from resource redundancy, uncontrollable updates, low efficiency, and poor adaptability in scenarios where multiple projects are deployed in parallel, and are unable to meet the performance, scalability, and resource coordination requirements of modern systems.
The server classifies front-end resources and generates public resources and project-private resources. The client loads and writes them into the cache in sequence. The server monitors resource changes in real time and generates risk scores. The client executes update strategies based on the scores and manages resources in combination with risk prediction models.
It improves resource loading performance and reuse efficiency, reduces the number of network requests, implements differentiated and controllable resource updates, avoids system anomalies caused by high-risk changes, and improves user experience.
Smart Images

Figure CN120541319B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of project resource loading methods, and in particular to a project resource loading method, apparatus, device, and storage medium. Background Art
[0002] With the development of Internet technology and the diversification of web application scenarios, the number of front-end projects is increasing. The customization requirements for front-end resources vary significantly between projects, and the complexity of resource management continues to rise. In addition, the size and number of resources such as HTML, CSS, JavaScript, and images continue to grow, resulting in decreased page loading efficiency and response delays, which seriously affect the user experience.
[0003] The resource loading strategies adopted in existing technologies are usually static packaging, browser caching and CDN optimization solutions. Although they have certain effects, they are difficult to meet the comprehensive requirements of performance, scalability and resource collaborative scheduling in modern systems with high demands for parallel deployment of multiple projects, frequent resource updates and shared reuse. At the same time, existing methods lack flexible loading strategies and caching mechanisms, and cannot take into account both personalized project loading requirements and overall system optimization goals. Summary of the Invention
[0004] The present application provides a project resource loading method that can achieve comprehensive optimization of resource loading efficiency, update strategy, parallel processing and stability in a multi-project environment, so as to at least solve the problems of resource redundancy, uncontrollable updates, low efficiency and poor adaptability in the scenario of multi-project parallel deployment in related technologies.
[0005] This application provides a project resource loading method, including:
[0006] The server classifies the front-end resources of multiple client projects stored in it into public resources and project-private resources.
[0007] In response to the client initially loading the project page, the client sequentially requests public resources and corresponding project private resources from the server, loads and writes them into the client's local cache;
[0008] The server monitors the project's private resources in real time to see if any changes have occurred. If so, it identifies the changed items through code comparison, uses the risk prediction model to generate risk level scores for the changed items, constructs a list of changed items with risk score tags, and encapsulates the list into a change data package and sends it to the client.
[0009] The client verifies the received change data packet based on the preset verification rules. If the verification passes, it parses the change item list and the corresponding risk level score, and executes the preset strategy according to the risk level score to update the client local cache.
[0010] The application also provides a project resource loading method and device, comprising:
[0011] The resource classification module is arranged on the server and is used for classifying the stored front-end resources of the plurality of client projects to obtain public resources and project private resources;
[0012] The resource request module is arranged on the client and is used for, in response to the initial loading of the project page by the client, sequentially requesting the public resources and the corresponding project private resources from the server, loading and writing into the local cache of the client;
[0013] The resource change monitoring module is arranged on the server and is used for monitoring whether the project private resources change in real time, and in response to the change, identifying the changed items through code comparison, generating a risk level score of the changed items by calling a risk prediction model, constructing a changed item list with the risk score mark and encapsulating the changed item list into a changed data packet and sending the changed data packet to the client;
[0014] The cache updating module is arranged on the client and is used for verifying the received changed data packet based on a preset verification rule, parsing the changed item list and the corresponding risk level score if the verification is passed, and updating the local cache of the client according to the risk level score and a preset strategy.
[0015] The application also provides an electronic device, comprising a memory for storing a computer program and a processor for executing the computer program to implement the steps of any one of the project resource loading methods.
[0016] The application also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of any one of the project resource loading methods.
[0017] Through the application, since the server pre-recognizes multiple projects deployed by the client and classifies the front-end resources, repeated loading of common modules can be avoided, bandwidth and browser resource occupation are reduced, loading performance and resource reuse efficiency are improved; at the same time, since the client can load public resources and project private resources in turn and write into local cache based on the resource division result provided by the server when initially loading the project page, cached resources can be directly read in subsequent access, loading speed is improved and the number of network requests is reduced; furthermore, since the server monitors changes in project private resources in real time, identifies specific changed items, and generates risk level scores for the changed items in combination with a risk prediction model, quantitative evaluation of the impact of resource updates can be realized, which helps to avoid system abnormalities caused by high-risk changes; in addition, after the client receives the changed data pushed by the server, a corresponding preset update strategy is executed based on the risk level score, so that a differentiated and controllable resource replacement process can be realized, and business interruption or front-end abnormalities caused by errors or high-risk updates can be avoided. BRIEF DESCRIPTION OF DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0019] Figure 1 An application environment schematic diagram provided for the embodiments of the present application;
[0020] Figure 2 A project resource loading method flowchart provided for the embodiments of the present application;
[0021] Figure 3 A project resource loading method step flowchart provided for the embodiments of the present application;
[0022] Figure 4 A client verification flowchart in a project resource loading method provided for the embodiments of the present application;
[0023] Figure 5 A project resource loading method device structure block diagram provided for the embodiments of the present application;
[0024] Figure 6 An electronic device structure schematic diagram provided for the embodiments of the present application. DETAILED DESCRIPTION
[0025] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0026] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.
[0027] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0028] This application provides a project resource loading method that can be applied to Figure 1 In the application environment shown. Among them, the client 102 communicates with the server 104 through the network. The user accesses the project page by using the browser of the client 102. When the client 102 loads the project page for the first time, it requests public resources and corresponding project private resources from the server 104 in sequence, loads them into the browser and writes them into the local cache of the client 102. The server 104 deploys the corresponding front-end resources respectively and monitors the project private resources in real time. When a change is detected, a list of change items with risk score marks is generated and encapsulated into a change data packet and sent to the client 102. After the client 102 receives the change data packet and verifies it, it executes a preset strategy based on the risk level score to update the client local cache, thereby realizing the current or subsequent project page update. This method is applicable to typical Web systems with parallel deployment of multiple projects, front-end resource sharing and differentiated loading requirements, and is particularly suitable for application scenarios such as micro-front-end architecture, SaaS multi-tenant system, and portal integration platform. Among them, the client 102 can be but is not limited to various personal computers, laptops, smart phones, tablets and portable wearable devices, and the server 104 can be implemented with an independent server or a server cluster consisting of multiple servers, supporting parallel deployment of multiple projects and unified resource scheduling.
[0029] It is worth noting that updating the client local cache by executing a preset strategy based on the risk level score is of great significance in practical applications. For example, in a typical scenario, considering system stability, if the change item is a newly added auxiliary style class and there is no control flow change and call chain impact, the system will be assessed as low risk and can be directly replaced; if the change involves user authentication logic, complex control structure, and has a history of causing serious defects, it will be assessed as high risk and a controlled loading strategy will be adopted; for example, in another typical scenario, considering user usage, taking the bank page as an example, when the user visits the page, the corresponding front-end resources stored in the server will be updated. For example, if the change item corresponds to the logo page or advertising page of the bank page, the client can directly update and replace it. However, if the change item corresponds to the transfer form page of the bank page, the client cannot directly update it and needs to adopt more cautious update strategies such as lazy update and asynchronous update.
[0030] like Figure 2 As shown, an embodiment of the present application provides a project resource loading method, including:
[0031] Step 201: The server classifies the front-end resources of multiple client projects stored therein to obtain public resources and project-private resources.
[0032] Step 202: In response to the client initially loading the project page, the client sequentially requests public resources and corresponding project private resources from the server, loads them, and writes them into the client's local cache;
[0033] Step 203: The server monitors the project's private resources in real time to see if any changes have occurred. If so, the server identifies the changed items through code comparison, invokes the risk prediction model to generate risk level scores for the changed items, constructs a list of changed items with risk score tags, encapsulates the list into a change data package, and sends it to the client. If not, no action is taken.
[0034] In step 204, the client verifies the received change data packet based on preset verification rules. If the verification passes, the client parses the change item list and the corresponding risk level score, and executes a preset policy according to the risk level score to update the client local cache.
[0035] Specifically, the project resource loading method provided in the present application pre-identifies multiple projects deployed by the client and classifies their front-end resources through the server, which can avoid repeated loading of common modules, reduce bandwidth and browser resource usage, and improve loading performance and resource reuse efficiency; at the same time, by loading public resources and project private resources in sequence based on the resource division results provided by the server when the project page is loaded for the first time, and writing them into the local cache, the cached resources can be directly read in subsequent accesses, thereby improving loading speed and reducing the number of network requests; furthermore, by real-time monitoring of changes in project private resources, identifying specific change items, and generating risk level scores for the change items in combination with the risk prediction model, a quantitative assessment of the impact of resource updates can be achieved, which helps to avoid system anomalies caused by high-risk changes; in addition, after the client receives the change data pushed by the server, the corresponding preset update strategy is executed based on the risk level score, thereby achieving a differentiated and controllable resource replacement process, avoiding business interruptions or front-end anomalies caused by errors or high-risk updates.
[0036] In one embodiment, the server classifies the front-end resources of multiple client projects stored therein to obtain public resources and project-private resources, including:
[0037] Get the project ID declared in the client, where the project ID can be the projectID set declared in the configuration file or interface parameters;
[0038] Based on the project ID, read the corresponding resource mapping configuration, determine the front-end resources and generate a list of resources to be classified;
[0039] Traverse the list of resources to be classified, and divide the front-end resources into public resources and project private resources based on the project reuse of the front-end resources.
[0040] Specifically, this embodiment ensures that the resource classification process is efficient and accurate, adapts to dynamic changes in projects, and improves the flexibility and automation of resource management through an automatic extraction and traversal mechanism based on project identification and resource mapping configuration.
[0041] In one embodiment, based on the project reuse of front-end resources, front-end resources are divided into public resources and project-private resources, including:
[0042] Get the number of projects deployed in the client and set a reuse threshold proportional to the number of projects. The ratio of the reuse threshold to the number of projects is preferably set to 0.6-0.8.
[0043] Count the number of application projects of front-end resources in turn and generate the project reuse degree of front-end resources;
[0044] In response to the project reuse degree of the front-end resource being greater than or equal to the reuse threshold, determining that the front-end resource is a public resource;
[0045] In response to the project reuse degree of the front-end resource being less than a reuse threshold, it is determined that the front-end resource is a project private resource.
[0046] It is worth noting that public resources can be resources such as UI libraries, basic style sheets, icon fonts, etc., while project private resources can be business codes, styles, and configuration files unique to each project.
[0047] Specifically, by introducing project reuse and dynamic threshold determination mechanisms in this embodiment, shared resources can be dynamically identified in a multi-project parallel deployment environment, thereby maximizing resource reuse rates and effectively reducing overall resource volume and loading overhead.
[0048] In one embodiment, Figure 3 As shown, after obtaining public resources and project private resources, it also includes:
[0049] Step 301: upload and deploy public resources to a shared server with a unified path;
[0050] Step 302: deploy the project private resources to the private paths associated with the corresponding projects;
[0051] Step 303: configure access control rules for public resources and project private resources respectively, and generate a resource deployment index table for the client to call when loading.
[0052] It is worth noting that the deployment of project private resources can use Kubernetes namespaces to allocate an independent operating environment for each project to ensure the physical isolation and security of resources; in addition, based on the Terraform tool, independent storage buckets can be created for the project to store the corresponding project private resources, and integrated with the CI / CD pipeline (GitHub Actions) to achieve full process automation from code submission to environment deployment.
[0053] Specifically, in this embodiment, by deploying resources by type to public and private paths, and configuring access control and index tables, resource isolation and secure access are achieved in a multi-tenant environment, thereby improving the maintainability and scalability of the system.
[0054] In one embodiment, in response to the client initially loading a project page, the client sequentially requests public resources and corresponding project private resources from the server, loads them into the browser interface, and writes them into the client's local cache, including:
[0055] The client sends a resource loading request to the server to obtain the resource deployment index table. The resource loading request includes at least the current running project identifier.
[0056] In response to the client receiving the resource deployment index table, the resource deployment index table is parsed to obtain a public resource path set and a project private resource path set corresponding to the current running project identifier;
[0057] Based on the public resource path set and the project private resource path set, request public resources and project private resources from the server in sequence;
[0058] In response to receiving the public resources and project-private resources fed back by the server, the public resources and project-private resources are loaded into the browser interface and written into the client's local cache.
[0059] Specifically, in this embodiment, the loading order is guided by the resource deployment index table, invalid pull and path resolution operations are reduced, efficient acquisition of first screen resources is achieved, system loading performance is improved, and the fast rendering requirements of modern Web systems are adapted.
[0060] In one embodiment, after loading the public resources and the project private resources into the browser interface and writing them into the client local cache, the process further includes:
[0061] In response to the client loading the project page again, the public resources and project private resources stored in the client's local cache are read and integrity verified, wherein the integrity verification may be based on the SHA256 digest value of the file stored in the client's local cache;
[0062] If the verification passes, the public resources and project private resources are loaded into the browser;
[0063] If the verification fails, the missing resource is determined and the resource request is resent to the server.
[0064] Specifically, in this embodiment, a local cache verification mechanism is introduced to ensure the integrity and correctness of loaded resources, avoid page errors caused by resource tampering or loss, and achieve stability and continuity of client resource loading.
[0065] In one embodiment, the server monitors in real time whether there are any changes to the project's private resources, including:
[0066] For deployed project private resources, extract the corresponding complete storage path, file content binary byte stream, and last modification timestamp;
[0067] The complete storage path, the binary byte stream of the file content, and the last modification timestamp are combined and calculated using a preset digest algorithm to generate an initial fingerprint digest of the project's private resources. The preset digest algorithm is preferably the SHA256 algorithm.
[0068] Based on the preset monitoring period, re-extract the current storage path, current file content binary byte stream and current timestamp corresponding to the project private resources to generate the current fingerprint summary of the project private resources. The preset monitoring period is preferably set to 5-8 minutes;
[0069] Compare the initial fingerprint digest with the current fingerprint digest. If they are consistent, it is determined that the project private resources have not changed. If they are inconsistent, it is determined that the project private resources have changed.
[0070] Specifically, in this embodiment, by generating structured summaries and performing periodic fingerprint comparisons, automatic change monitoring can be achieved without relying on external version control tools, thereby improving resource version synchronization efficiency and reducing manual intervention costs.
[0071] In one embodiment, identifying the changed items through code comparison includes:
[0072] Build a comparison sample of the pre-change and post-change versions of the project's private resources;
[0073] Parse the comparison samples based on the abstract syntax tree algorithm, extract grammatical structure information, and identify grammatical structure difference features and corresponding grammatical node change positions. The grammatical structure difference features include function position changes, control structure changes, etc.
[0074] Based on the control flow graph construction algorithm, the control flow graph is extracted from the source code of the comparison sample, and the control flow graph before and after the change are generated. The control flow change path and the impact range of the control flow change are compared;
[0075] Extract the calling relationships between functions in the comparison samples, build a global call chain graph, identify the call chain fragments controlled by the control flow change path, and generate call chain information;
[0076] Determine the granularity of the change based on the location of the syntax node change and the scope of the control flow change.
[0077] In response to the granularity level of the change impact granularity being the file level, the affected downstream files are identified as change items based on the control flow change path, the call chain information, and the control flow change impact scope;
[0078] In response to the granularity level of the change impact granularity being the function level, the affected downstream functions are identified as change items based on the control flow change path, call chain information, and the control flow change impact scope;
[0079] Generate change item information based on the change item, combine the syntax structure difference characteristics, control flow change path, call chain information and change impact granularity to construct a change feature vector for the risk prediction model to call.
[0080] Specifically, in the embodiment, the code change is structurally identified and impact evaluated by combining syntax tree and control flow graph, so as to improve the precision and granularity of difference identification and provide technical support for accurate resource update.
[0081] In one embodiment, a risk prediction model is called to generate a risk level score for the change item, including:
[0082] The historical change data corresponding to the change item is parsed to obtain a historical defect rate, a historical fault correlation score and a historical rollback frequency, and combined with the change feature vector to generate a combined input feature;
[0083] A risk prediction model is constructed based on a supervised learning algorithm, and the risk prediction model is trained according to the historical change data combined with a preset loss function. In response to the preset loss function converging to a preset confidence threshold, it is determined that the risk prediction model training is completed;
[0084] In response to the risk prediction model training being completed, the combined input feature is input into the risk prediction model, and a corresponding risk level score is output.
[0085] Specifically, in the embodiment, the historical defect data is combined with the change feature to construct a trainable risk prediction model, which provides a quantitative decision basis for resource update and prevents high-risk changes from affecting system stability.
[0086] In one embodiment, a risk prediction model is constructed based on a supervised learning algorithm, and the risk prediction model is trained according to the historical change data combined with a preset loss function. In response to the preset loss function converging to a preset confidence threshold, it is determined that the risk prediction model training is completed, including:
[0087] The server constructs a standardized sample set for model training, each sample corresponding to a historical change item, containing the following feature dimensions: syntax structure difference feature, control flow graph change path, call chain depth, change granularity identification, historical defect rate, historical fault rollback frequency, change frequency, etc. After unified normalization processing, the sample input feature vector is obtained, denoted as , as the model input;
[0088] A single-hidden-layer feedforward neural network structure is used to construct the risk prediction model, with the input layer dimension n, the hidden layer node number m, and the output as a single continuous score value , wherein the expression of the risk prediction model is:
[0089] ;
[0090] wherein and are the weight matrix and the bias vector from the input layer to the hidden layer, respectively. and is the weight and bias vector from the hidden layer to the output layer; ReLU(z)=max(0,z) is the activation function from the input layer to the hidden layer; The Sigmoid function limits the output risk level score to 0-1;
[0091] The sample input feature vector is input into the risk prediction model and trained by minimizing the mean square error loss function with a regularization term. The loss function is:
[0092] ;
[0093] Among them, θ is the model parameter set, y i is the real risk level label, is the model prediction output, N is the number of training samples, and λ is the regularization coefficient;
[0094] During the training process, the server uses a cross-validation strategy to dynamically evaluate the model performance. If the loss of the validation set decreases below the set threshold, such as 0.001, over multiple consecutive evaluation cycles, and the final loss function value converges to a preset trust threshold, such as 0.05, the training is considered complete and the model is persisted in the server scoring module.
[0095] Specifically, the trained model in this embodiment can be called when running on the server to make real-time predictions on the change items to be scored, and output the corresponding risk level score value as the decision-making basis for the client update strategy, so that when cache resources face change items of different risk levels, they can adopt hierarchical processing methods such as automatic replacement, primary and backup coexistence, or lazy loading, thereby ensuring the security, stability and controllability of resource updates; at the same time, the risk prediction model constructed in the above manner not only has good generalization ability and interpretability, but also can flexibly select different model frameworks such as lightweight neural networks, random forests, support vector machines, etc. according to the platform deployment environment, while meeting the risk scoring requirements and optimizing the model deployment performance.
[0096] In one embodiment, a change list with risk score tags is constructed and packaged into a change data package and sent to the client, including:
[0097] Parse multiple change item information to obtain the change item identifiers, change item version numbers, and change item path information corresponding to the multiple change items, and generate a change item list containing multiple change item entries in combination with the corresponding risk level scores;
[0098] SHA256 algorithm is preferred to perform digest calculation on the change list to generate summary information;
[0099] Based on the preset project private signature key, a signature operation is performed on the summary information to generate a signature field, wherein the project private signature key is preferably set based on the RSA signature algorithm;
[0100] The change item list, summary information, and signature fields are encapsulated into a change data package and actively pushed to the client.
[0101] Specifically, in this embodiment, the security and credibility of the resource push process are improved by using a summary signature and a fully encapsulated change data packet, thereby preventing the change process from being tampered with or forged, and ensuring that client resource updates are safe and reliable.
[0102] In one embodiment, Figure 4 As shown, the client verifies the received change data packet based on preset verification rules, including:
[0103] Parse the received change data packet to obtain the change item list, summary information and signature field;
[0104] The change list is digested using a preset digest algorithm consistent with the server to generate client-side local digest information. The preset digest algorithm is preferably the SHA256 algorithm.
[0105] Compare the client's local summary information with the summary information. If they are inconsistent, the verification is terminated and the verification is deemed to have failed. If they are consistent, the verification continues.
[0106] Decrypt the signature field based on the summary information and the client's local preset public key to generate a decrypted summary value;
[0107] Compare the decrypted digest value with the client's local digest information. If they are inconsistent, the verification is terminated and the verification is judged to have failed. If they are consistent, the verification is judged to have passed.
[0108] Specifically, in this embodiment, a double summary and public key signature mechanism is used to ensure the integrity and authenticity of the resource change package, effectively resist the risks of man-in-the-middle attacks and malicious injections, and enhance the security protection capabilities of the front-end resource update link.
[0109] In one embodiment, parsing the list of changed items and the corresponding risk level scores, and executing a preset policy based on the risk level scores to update the client local cache includes:
[0110] Parse the change item list to obtain the change item identifiers, change item version numbers, change item path information, and risk level scores corresponding to multiple change items;
[0111] Based on the changed item identifier, locate the corresponding cache resource in the client's local cache;
[0112] In response to the risk level score being less than the first risk threshold, the change item is determined to be low risk, and the corresponding update resource is directly requested from the server according to the change item path information to replace the cached resource. The version number and timestamp recorded in the client's local cache are updated based on the change item version number and the current timestamp. The first risk threshold is preferably set to 0.2. After replacing the cached resource, the browser page can be directly replaced through the hot update method without refreshing the page.
[0113] In response to the risk level score being greater than or equal to the first risk threshold and less than the second risk threshold, the change item is determined to be medium risk, an asynchronous thread is started based on the change item path information to request the corresponding resource from the server as a backup resource, the cached resource is retained as the primary resource, the resource upgrade status is recorded based on the change item version number, and a switching strategy is configured to perform a primary-backup switching under preset switching conditions, wherein the second risk threshold is preferably set to 0.6, and the configured switching strategy includes: performing a primary-backup switching when the browser page is refreshed next time;
[0114] In response to the risk level score being greater than or equal to the second risk threshold, the change item is determined to be high risk, the cached resource is set to restricted access to prevent the front-end from automatically loading, and a lazy loading strategy is set to request the corresponding updated resource from the server under preset loading conditions, wherein the lazy loading strategy is to request the corresponding updated resource from the server only when the user explicitly accesses the resource corresponding to the change item, such as a browser page area;
[0115] Specifically, in this embodiment, update strategies are divided according to risk levels, making resource updates more flexible and controllable, avoiding high-risk resources from directly replacing existing caches, ensuring stable system operation while taking into account responsiveness.
[0116] In a preferred embodiment, the client executes a preset policy based on the risk level score to update the client local cache, further comprising:
[0117] Based on the parsed list of changed items, the client obtains the current browser's operating information and collects user behavior data in the accessed projects, including but not limited to: click frequency, page dwell time, input focus active status, scrolling behavior, and page switching frequency;
[0118] The collected user behavior characteristics are classified and analyzed to generate the user operation status of the current operation session. The status may include but is not limited to the following types: idle state, that is, the browser page has no interaction for a long time; active click state, that is, the user frequently clicks buttons or controls; key information input state, that is, the user is entering information such as forms, passwords, and key configuration fields; page jump or loading state, that is, the user is initiating a new page request.
[0119] Based on the user's operation state, combined with the interaction sensitivity and operation risk corresponding to each state, a user state score is generated. Among them, the idle state corresponds to a lower score, and the key information input state corresponds to a higher score. The user state score is positively correlated with the operation sensitivity;
[0120] The client combines the user status score with the risk level score of the change item, for example, by using a weighted linear combination or rule mapping method, to generate a final joint assessment value.
[0121] Based on the joint evaluation value, the client reselects and executes the corresponding preset resource update strategy, including but not limited to: cold update, asynchronous loading, delayed loading, setting lazy loading flag, and limiting automatic loading to be triggered after idle time.
[0122] Specifically, in this embodiment, through the above-mentioned mechanism, the resource update method provided by this application can realize dynamic decision-making based on user status perception, and avoid front-end resource overloading caused by high-risk change items during user interaction sensitive periods, such as filling out forms and editing configurations, thereby improving interaction continuity and operational security; when the user is idle or in low activity, the update of cache resources is completed first to improve system resource utilization; avoid overly conservative or radical update problems caused by unified strategies, and realize personalized and intelligent cache update scheduling; improve the context relevance of cache replacement strategies, adapt to diverse user behavior scenarios, and enhance system robustness.
[0123] In one embodiment, after the client executes a preset policy based on the risk level score to update the client local cache, the method further includes:
[0124] Maintain a local version track linked list corresponding to the changed item to support fallback protection of cached resources. The version track linked list is used to record the historical version information of the target changed item. Each record includes but is not limited to: the changed item identifier, resource version number, update timestamp, risk level score, fallback available flag, and the storage path of the cached resource file;
[0125] Each time the client performs a replacement operation on the cached resources of a change item, it adds a new record to the version trajectory list corresponding to the change item and sets it as the current version node; if the length of the trajectory list exceeds the preset threshold, such as the record does not exceed 5 historical versions, the earliest old version record is automatically deleted.
[0126] It is worth noting that if the client detects an anomaly in the cached resource, such as a loading failure, integrity check failure, missing resource file, or the risk level score of the corresponding change item is higher than the preset security threshold, a rollback operation is triggered, including the following steps: traverse the version trajectory list of the change item, find the most recent version record with a risk level score lower than the preset threshold and a rollback available flag of "available"; load the old version cached resource file and replace the current main resource file; update the cache resource status flag, set the rolled back version as the main resource version, and mark the erroneous version as a backup or frozen state; record the rollback behavior in the local log system, and optionally report the corresponding rollback summary information to the server, including the failed version number, rollback version number, triggering reason, etc.
[0127] Specifically, the version track linked list and automatic rollback mechanism constructed in this embodiment can achieve self-recovery and rollback of cache resources when abnormalities or high risks occur during the resource update process, effectively improving the system's fault tolerance and operation continuity, and is suitable for front-end application scenarios with high availability requirements.
[0128] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method.
[0129] The embodiment of the present application also provides a project resource loading method and device, such as Figure 5 As shown, it includes: resource classification module, resource request module, resource change monitoring module and cache update module, among which,
[0130] The resource classification module is deployed on the server side and is used to classify the front-end resources of multiple client projects stored in the system into public resources and project-private resources.
[0131] The resource request module is deployed on the client and is used to respond to the client initially loading the project page. It then requests public resources and corresponding project private resources from the server in sequence, loads them into the browser, and writes them into the client's local cache.
[0132] The resource change monitoring module is deployed on the server side and is used to monitor in real time whether there are any changes to the project's private resources. If so, it identifies the changed items through code comparison, uses the risk prediction model to generate risk level scores for the changed items, builds a list of changed items with risk score tags, and encapsulates them into a change data package and sends it to the client.
[0133] The cache updating module is arranged at the client and is configured to verify the received change data packet based on a preset verification rule, parse a change item list and a corresponding risk level score if the verification is passed, and update the local cache of the client according to a preset strategy based on the risk level score.
[0134] The resource classification module is further configured to obtain a project identifier declared in the client, read a corresponding resource mapping configuration based on the project identifier, determine a front-end resource and generate a to-be-classified resource list, and traverse the to-be-classified resource list, and divide the front-end resource into a public resource and a project private resource based on a project reuse degree of the front-end resource.
[0135] The resource classification module is further configured to obtain a number of projects deployed in the client, set a reuse threshold that is proportional to the number of projects based on the number of projects, and generate the project reuse degree of the front-end resource by sequentially counting a number of application projects of the front-end resource, determine the front-end resource as the public resource in response to the project reuse degree of the front-end resource being greater than or equal to the reuse threshold, and determine the front-end resource as the project private resource in response to the project reuse degree of the front-end resource being less than the reuse threshold.
[0136] The resource classification module is further configured to upload and deploy the public resource to a shared server at a uniform path, deploy the project private resource to a private path associated with a corresponding project, and configure an access control rule for the public resource and the project private resource respectively, and generate a resource deployment index table for calling by the client when loading.
[0137] The resource request module is further configured to send a resource loading request to the server to obtain the resource deployment index table, the resource loading request at least including a current running project identifier, parse the resource deployment index table to obtain a public resource path set and a project private resource path set corresponding to the current running project identifier in response to the client receiving the resource deployment index table, sequentially request the public resource and the project private resource from the server based on the public resource path set and the project private resource path set, and load the public resource and the project private resource to a browser interface and write the public resource and the project private resource into the local cache of the client in response to receiving the public resource and the project private resource fed back by the server.
[0138] The resource request module is further configured to read the public resource and the project private resource stored in the local cache of the client and verify the integrity in response to the client loading the project page again, load the public resource and the project private resource to the browser if the verification is passed, and determine a missing resource and resend a resource request to the server if the verification is not passed.
[0139] The resource change monitoring module is further configured to extract a complete storage path, a file content binary byte stream, and a last modification timestamp corresponding to the project private resource for which the deployment is completed; generate an initial fingerprint digest of the project private resource by combining and calculating the complete storage path, the file content binary byte stream, and the last modification timestamp through a preset digest algorithm; based on a preset monitoring period, re-extract a current storage path, a current file content binary byte stream, and a current timestamp corresponding to the project private resource, and generate a current fingerprint digest of the project private resource; compare the initial fingerprint digest and the current fingerprint digest, and if they are consistent, determine that the project private resource has not changed, and if they are inconsistent, determine that the project private resource has changed.
[0140] The resource change monitoring module is further configured to construct a comparison sample of a pre-change version and a post-change version of the project private resource; parse the comparison sample based on an abstract syntax tree algorithm, extract syntax structure information, and identify syntax structure difference features and corresponding syntax node change positions; extract a control flow graph from the source code of the comparison sample based on a control flow graph construction algorithm, generate a pre-change control flow graph and a post-change control flow graph, and compare them to obtain a control flow change path and a control flow change impact range; extract function-to-function call relationships in the comparison sample, construct a global call chain graph, identify call chain segments controlled by the control flow change path, and generate call chain information; determine a change impact granularity according to the syntax node change positions and in combination with the control flow change impact range; in response to the granularity level of the change impact granularity being file level, identify affected downstream files as change items according to the control flow change path, the call chain information, and the control flow change impact range; in response to the granularity level of the change impact granularity being function level, identify affected downstream functions as change items according to the control flow change path, the call chain information, and the control flow change impact range; generate change item information according to the change items, and construct a change feature vector in combination with the syntax structure difference features, the control flow change path, the call chain information, and the change impact granularity for calling by a risk prediction model.
[0141] The resource change monitoring module is further configured to parse historical change data corresponding to the change items to obtain a historical defect rate, a historical fault correlation score, and a historical rollback frequency, and combine the historical change data with the change feature vector to generate a combined input feature; construct a risk prediction model based on a supervised learning algorithm, and train the risk prediction model according to the historical change data in combination with a preset loss function; in response to the preset loss function converging to a preset confidence threshold, determine that the training of the risk prediction model is complete; in response to the training of the risk prediction model being complete, input the combined input feature into the risk prediction model to output a corresponding risk level score.
[0142] The resource change monitoring module is also used to parse multiple change item information, obtain change item identifiers, change item version numbers, and change item path information corresponding to the multiple change items, and generate a change item list containing multiple change item entries in combination with the corresponding risk level scores; perform summary calculation on the change item list to generate summary information; based on the preset project private signature key, perform a signing operation on the summary information to generate a signature field; encapsulate the change item list, summary information, and signature field into a change data packet, and actively push it to the client.
[0143] The cache update module is also used to parse the received change data packet to obtain a list of change items, summary information and signature fields; perform summary calculation on the list of change items using a preset summary algorithm consistent with the server to generate client local summary information; compare the client local summary information with the summary information, and if they are inconsistent, terminate the verification and determine that the verification has failed; if they are consistent, continue the verification; decrypt the signature field based on the summary information and the client's local preset public key to generate a decrypted summary value; compare the decrypted summary value with the client local summary information, and if they are inconsistent, terminate the verification and determine that the verification has failed; if they are consistent, determine that the verification has passed.
[0144] The cache update module is also used to parse the change item list to obtain change item identifiers, change item version numbers, change item path information and risk level scores corresponding to multiple change items; based on the change item identifiers, the corresponding cache resources are located in the client local cache; in response to the risk level score being less than the first risk threshold, the change item is determined to be low risk, and the corresponding update resource is directly requested from the server according to the change item path information to replace the cache resource, and the version number and timestamp recorded in the client local cache are updated based on the change item version number and the current timestamp; in response to the risk level score being greater than or equal to the first risk threshold and less than the second risk threshold, the change item is determined to be medium risk, and an asynchronous thread is started based on the change item path information to request the corresponding resource from the server as a backup resource, retaining the cache resource as the main resource, recording the resource upgrade status based on the change item version number and configuring the switching strategy to perform the main-backup switching under the preset switching conditions; in response to the risk level score being greater than or equal to the second risk threshold, the change item is determined to be high risk, the cache resource is set to restricted access to prevent the front-end from automatically loading, and a lazy loading strategy is set to request the corresponding update resource from the server under the preset loading conditions.
[0145] For the description of the features in the embodiment corresponding to the project resource loading method device, please refer to the relevant description of the embodiment corresponding to the project resource loading method, which will not be repeated here.
[0146] The embodiment of the present application also provides an electronic device, such as Figure 6As shown, it includes a memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any of the above project resource loading method embodiments.
[0147] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned project resource loading method embodiments when running.
[0148] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disk.
[0149] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above-mentioned project resource loading method embodiments are implemented.
[0150] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above-mentioned project resource loading method embodiments are implemented.
[0151] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0152] The above is a detailed introduction to a project resource loading method, device, equipment, storage medium and product provided by this application. Specific examples are used herein to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core idea of this application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to this application, and these improvements and modifications also fall within the scope of protection of this application.
Claims
1. A project resource loading method, characterized in that: include: The server classifies the front-end resources of multiple client projects stored in it into public resources and project-private resources. In response to the client initially loading the project page, the client sequentially requests the public resources and the corresponding project private resources from the server, loads and writes them into the client local cache; The server monitors in real time whether changes have occurred to the project's private resources. In response to changes, it identifies the changed items through code comparison, invokes a risk prediction model to generate a risk level score for the changed items, constructs a list of changed items with risk score tags, encapsulates the list into a change data packet, and sends it to the client; The client verifies the received change data packet based on preset verification rules, and if the verification passes, parses the change item list and the corresponding risk level score, and executes a preset strategy according to the risk level score to update the client local cache.
2. The project resource loading method according to claim 1, characterized in that: The server classifies the front-end resources of multiple client projects stored therein to obtain public resources and project private resources, including: Obtaining the project identifier declared in the client; Based on the project identifier, read the corresponding resource mapping configuration, determine the front-end resources and generate a list of resources to be classified; The to-be-classified resource list is traversed, and based on the project reuse of the front-end resources, the front-end resources are sequentially divided into the public resources and the project private resources.
3. The project resource loading method according to claim 1, characterized in that: After obtaining public resources and project private resources, it also includes: Uploading and deploying the public resources to a shared server with a unified path; Deploy the project private resources to the private paths associated with the corresponding projects respectively; Access control rules are configured for the public resources and the project private resources respectively, and a resource deployment index table is generated for the client to call when loading.
4. The project resource loading method according to claim 1, characterized in that: The identification of the changed items through code comparison includes: Construct a comparison sample of the pre-change version and the post-change version of the private resources of the project; Parsing the comparison samples based on the abstract syntax tree algorithm, extracting grammatical structure information, and identifying grammatical structure difference features and corresponding grammatical node change positions; Based on a control flow graph construction algorithm, a control flow graph is extracted from the source code of the comparison sample, a control flow graph before the change and a control flow graph after the change are generated, and the control flow change path and the control flow change impact range are obtained by comparison; Extracting the calling relationship between functions in the comparison sample, constructing a global call chain graph and identifying the call chain fragments controlled by the control flow change path, and generating call chain information; Determining the change impact granularity based on the syntax node change position and the control flow change impact range; In response to the granularity level of the change impact granularity being the file level, identifying the affected downstream files as the change items according to the control flow change path, the call chain information, and the control flow change impact range; In response to the granularity level of the change impact granularity being the function level, identifying the affected downstream function as the change item according to the control flow change path, the call chain information, and the control flow change impact range; Change item information is generated based on the change item, and a change feature vector is constructed in combination with the grammatical structure difference characteristics, the control flow change path, the call chain information and the change impact granularity for the risk prediction model to call.
5. The project resource loading method according to claim 4, characterized in that: The calling of the risk prediction model to generate a risk level score for the change item, constructing a change item list with risk score marks and encapsulating the list into a change data packet and sending the data packet to the client includes: Parsing the historical change data corresponding to the change item to obtain a historical defect rate, a historical fault correlation score, and a historical rollback frequency, and combining them with the change feature vector to generate a combined input feature; Inputting the combined input features into the trained risk prediction model, and outputting the corresponding risk level score; Parsing the multiple change item information to obtain change item identifiers, change item version numbers, and change item path information corresponding to the multiple change items, and generating the change item list containing multiple change item entries in combination with the corresponding risk level scores; Performing summary calculation on the list of changed items to generate summary information; Based on the preset project private signature key, a signature operation is performed on the summary information to generate a signature field; Encapsulating the change item list, the summary information, and the signature field into the change data packet, and actively pushing the data packet to the client; Before calling the risk prediction model, the method further includes: Constructing the risk prediction model based on a supervised learning algorithm, and training the risk prediction model based on historical change data corresponding to a standardized sample set in combination with a preset loss function; In response to the preset loss function converging to a preset credibility threshold, it is determined that the risk prediction model training is completed.
6. The project resource loading method according to claim 5, characterized in that: The client verifies the received change data packet based on a preset verification rule, including: Parsing the received change data packet to obtain the change item list, the summary information, and the signature field; Performing digest calculation on the list of changed items using a preset digest algorithm consistent with that of the server to generate client-side local digest information; Comparing the client's local summary information with the summary information, terminating the verification and determining that the verification fails if they are inconsistent, and continuing the verification if they are consistent; Decrypt the signature field based on the summary information and a public key preset locally on the client to generate a decrypted summary value; The decrypted digest value is compared with the client local digest information. If they are inconsistent, the verification is terminated and the verification is determined to be failed. If they are consistent, the verification is determined to be successful.
7. The project resource loading method according to claim 6, characterized in that: The parsing of the change item list and the corresponding risk level score, and executing a preset strategy according to the risk level score to update the client local cache, includes: Parsing the change item list to obtain the change item identifiers, the change item version numbers, the change item path information, and the risk level scores corresponding to the multiple change items; Based on the changed item identifier, locating a corresponding cache resource in the client local cache; In response to the risk level score being less than a first risk threshold, determining that the changed item is low risk, directly requesting a corresponding update resource from the server according to the changed item path information to replace the cached resource, and updating the version number and timestamp recorded in the client local cache based on the changed item version number and the current timestamp; In response to the risk level score being greater than or equal to a first risk threshold and less than a second risk threshold, determining that the change item is of medium risk, initiating an asynchronous thread based on the change item path information to request a corresponding resource from the server as a backup resource, retaining the cached resource as the primary resource, recording a resource upgrade status based on the change item version number, and configuring a switching strategy to perform a primary-backup switching; In response to the risk level score being greater than or equal to a second risk threshold, the change item is determined to be high risk, the cache resource is set to restricted access to prevent the front end from automatically loading, and a lazy loading strategy is set to request the corresponding updated resource from the server.
8. A project resource loading device, characterized in that: include: The resource classification module is deployed on the server side and is used to classify the front-end resources of multiple client projects stored in the system into public resources and project-private resources. A resource request module is deployed on the client and is used to request the public resources and the corresponding private resources of the project from the server in sequence in response to the client initially loading the project page, and load and write them into the client local cache; A resource change monitoring module, deployed on the server side, is used to monitor in real time whether changes have occurred to the project's private resources. If so, it identifies the changed items through code comparison, invokes a risk prediction model to generate a risk level score for the changed items, constructs a list of changed items with risk score tags, encapsulates the list into a change data packet, and sends it to the client; A cache update module is deployed on the client and is used to verify the received change data packet based on preset verification rules. If the verification passes, the change item list and the corresponding risk level score are parsed, and a preset strategy is executed according to the risk level score to update the client local cache.
9. An electronic device, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the project resource loading method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, the steps of the project resource loading method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Network resource loading method and system, electronic equipment and storage medium
CN119342052A
Intelligent caching method and device for loading front-end resources as required, equipment and medium
CN119691305A