Website static resource dynamic loading method, system, device and medium

CN122802329APending Publication Date: 2026-09-22ZUNHUA LONGFEI NETWORK TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611096329.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-23
Publication Date
2026-09-22

AI Technical Summary

Technical Problem

[0003]具体的,现有网站静态资源加载方式多采用同步加载、按需懒加载或基于简单规则的预加载策略,同步加载会因资源阻塞导致首屏加载延迟过高,而常规懒加载与预加载技术存在诸多技术缺陷

Benefits of technology

[0055]上述网站静态资源动态加载方法、系统、设备及介质,首先通过静态分析与拓扑排序构建资源依赖图并计算共享度分数,解决了传统加载方式依赖解析粒度粗、资源优先级混乱及循环依赖异常的问题,实现了资源结构的精细化建模。其次,通过行为特征编码器进行时序建模,并结合图注意力网络预测资源访问概率,突破了单一行为感知局限,实现了用户意图的刻画与资源访问的预测。进一步的,基于置信度阈值进行高置信资源筛选与低置信资源的容量受限保序加载,兼顾了预加载命中率与带宽利用率,避免了非必要资源的过度加载与冷启动场景下的带宽浪费。最后,通过首屏关键性标签配置预加载指令并按拓扑逆序注入HTML头部执行加载,保障了关键资源的优先就绪与依赖关系的正确解析,增强了首屏渲染速度、页面切换流畅度及动态网络环境下的自适应加载能力。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122802329A_ABST
    Figure CN122802329A_ABST
Patent Text Reader

Abstract

The application relates to a website static resource dynamic loading method, system, device and medium. The method comprises the following steps: performing static analysis on a plurality of static resource modules of a target website, constructing a resource dependency graph and calculating a sharing degree score and a topological sorting sequence; collecting a user heterogeneous behavior sequence in real time, generating a behavior intention vector through an encoder, combining a graph attention network to output a resource access probability; dividing resources based on confidence, screening high-confidence resources according to probability, triggering a topological order-preserving strategy for low-confidence resources, determining a capacity upper limit according to network bandwidth and user residence time, selecting resources according to priority scores to obtain different candidate resources, merging to obtain a final preload set, and configuring a preload instruction to execute resource preloading according to a topological inverse sequence. The method significantly improves the preload hit rate and resource utilization efficiency and improves the website access fluency by fusing the resource dependency topology, user behavior intention and network state dynamic preloading decision.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer technology, and in particular relates to methods, systems, devices and media for dynamically loading static resources on websites. Background Technology

[0002] With the rapid development of front-end technologies in the Internet, single-page applications and modular development models have become the mainstream ways to build websites. Furthermore, the scale of static resources contained in websites, such as JavaScript, CSS style files, images, and fonts, continues to expand. The loading efficiency of static resources directly determines the website's first screen rendering speed, page switching smoothness, and overall user experience.

[0003] Specifically, existing website static resource loading methods mostly employ synchronous loading, on-demand lazy loading, or preloading strategies based on simple rules. Synchronous loading can lead to excessively high latency in first-screen loading due to resource congestion, while conventional lazy loading and preloading technologies have several technical shortcomings. On the one hand, existing static resource loading solutions can only perform shallow analysis of resource dependencies, failing to construct fine-grained resource dependency topologies and making it difficult to identify resource sharing characteristics and loading priorities. This can easily lead to problems such as abnormal loading of circular dependencies, repeated loading of common resources, or delayed loading of critical resources. On the other hand, existing static resource loading technologies only perceive user behavior in a single discrete event such as clicks and page jumps, without integrating continuous behavior metrics and multi-dimensional features such as device, network, and page context. This makes it impossible to accurately characterize user access intentions, resulting in low accuracy in resource access prediction. Furthermore, current preloading decision models do not deeply integrate resource dependency structures with user behavioral intentions and lack an adaptive confidence judgment mechanism. In cold start scenarios of user access behavior, they are prone to problems such as low preloading hit rate, wasted bandwidth resources, or excessive preloading of unnecessary resources. Moreover, most loading strategies are fixed rule patterns and cannot be iteratively optimized over a long period of time based on actual operating data. The preloading order and resource selection logic are difficult to adapt to the dynamically changing network environment and user access habits. Summary of the Invention

[0004] Therefore, it is necessary to provide methods, systems, devices, and media for dynamically loading static resources on websites to address the aforementioned technical issues, aiming to improve the accuracy and adaptability of static resource preloading, and enhance the first-screen rendering speed and user access experience.

[0005] Firstly, this application provides a method for dynamically loading static resources on a website, including:

[0006] S1. Perform static analysis on multiple static resource modules of the target website, extract the static attributes of each resource module, and construct a resource dependency graph; perform topological sorting on the resource dependency graph to obtain the topological sorting sequence, and calculate the sharing score of each resource module based on the resource dependency graph; static attributes include key tags on the first screen.

[0007] S2. Collect heterogeneous user behavior sequences in real time, perform temporal modeling on the heterogeneous behavior sequences through a behavior feature encoder, and generate user behavior intent vectors; input the resource dependency graph and user behavior intent vectors into a graph attention network, and output the access probability of each resource module; wherein, the heterogeneous behavior sequences include discrete behavior events, continuous behavior metrics and context state features.

[0008] S3. Calculate the confidence level of each resource module based on the access probability, and take the resource modules with a confidence level not lower than the preset confidence threshold as the first type of candidate resources. Filter resources according to the access probability of the first type of candidate resources to obtain the first preloaded candidate set.

[0009] S4. Resource modules with confidence levels lower than the preset confidence threshold are designated as second-class candidate resources. The topology order-preserving loading strategy is triggered. The upper limit of the preload capacity is calculated based on the current network bandwidth and the estimated user dwell time. Unloaded resource modules are extracted from the second-class candidate resources from the topology sorting sequence. The priority score of each unloaded resource module is calculated. Unloaded resource modules are selected in descending order of priority score and added to the second preload candidate set until the total volume of the second preload candidate set reaches the upper limit of the preload capacity, thus obtaining the final second preload candidate set.

[0010] S5. Merge the first preload candidate set with the final second preload candidate set to obtain the final preload resource set; configure preload instructions based on the first screen key tags of each resource module in the final preload resource set. The preload instructions are used to instruct the creation of corresponding link tags in reverse order of the topological sorting sequence, and insert the link tags into the HTML document head to perform resource preload operation.

[0011] In one embodiment, the behavior feature encoder includes a type-aware embedding layer, a temporal coding layer and an intent output layer. The type-aware embedding layer includes a discrete event embedding matrix, a continuous metric projection linear layer, a context projection linear layer and a splicing compression linear layer. The temporal coding layer is a multi-layer Transformer encoder.

[0012] The behavioral feature encoder is trained through the following steps:

[0013] Obtain discrete behavioral events, continuous behavioral metrics, and contextual state features from historical user sessions, align them by timestamps, and generate historical heterogeneous behavior sequences.

[0014] The actual resource accesses that occurred in the historical user sessions corresponding to each historical heterogeneous behavior sequence are used as supervision labels;

[0015] The trainable parameters of the behavior feature encoder are pre-trained using the cross-entropy loss function to obtain the trained behavior feature encoder.

[0016] The trainable parameters include the discrete event embedding matrix, the continuous metric projection linear layer, the context projection linear layer, the splicing compression linear layer, the parameters of the Transformer encoder, and the linear transformation parameters of the intent output layer.

[0017] In one embodiment, the graph attention network includes a feature construction layer, multiple attention propagation layers, and an output layer;

[0018] Input the resource dependency graph and user behavior intent vector into the graph attention network, and output the access probability of each resource module, including:

[0019] S201: Obtain the loaded status of each resource module. Through the feature construction layer, construct the initial feature vector of each resource node based on the static attributes and loaded status of each resource module in the resource dependency graph. Learn the globally shared weight matrix based on the attention propagation layers of the graph attention network.

[0020] S202: The features of each resource node in the current layer are linearly transformed using the weight matrix to obtain the transformed features; where, when the current layer is the first attention propagation layer, the features of each resource node in the current layer are the corresponding initial feature vectors;

[0021] S203: For each directed edge in the resource dependency graph, define the edge pointing to the target node as the incoming edge, obtain the transformation features of the source node and the transformation features of the target node of the directed edge; perform a linear transformation on the user behavior intent vector through the intent projection matrix to obtain the intent projection vector.

[0022] S204: Concatenate the transformation features of the source node, the transformation features of the target node, and the intention projection vector along the feature dimension to obtain a joint vector; perform a dot product operation on the joint vector and the preset attention parameter vector to obtain the dot product result; activate the dot product result through the LeakyReLU activation function to obtain the unnormalized attention score of the corresponding directed edge.

[0023] S205: Normalize the unnormalized attention scores of each incoming edge of each target node to obtain the normalized attention coefficients of each incoming edge; use the normalized attention coefficients to perform a weighted summation of the transformation features of the target node's neighboring nodes to obtain the feature representation of the target node at the next layer.

[0024] S206: Use the feature representation of the next layer of the target node as the feature of the current layer processed by the next attention propagation layer, repeat S202 to S205, and perform multi-layer feature propagation. When the propagation reaches the preset last layer, the final feature representation of each resource node is obtained. Input the final feature representation of each resource node into the output layer, perform Sigmoid activation, and obtain the access probability of each resource module.

[0025] In one embodiment, the upper limit of preload capacity is calculated based on the current network bandwidth and the estimated user dwell time. Unloaded resource modules are extracted from the second type of candidate resources from the topology sorting sequence. The priority score of each unloaded resource module is calculated. Unloaded resource modules are selected in descending order of priority score and added to the second preload candidate set until the total volume of the second preload candidate set reaches the upper limit of preload capacity, thus obtaining the final second preload candidate set, including:

[0026] Read the sharing score of each resource module from the resource dependency graph, obtain the maximum sharing of the entire graph in the resource dependency graph, calculate the ratio of each sharing score to the maximum sharing of the entire graph, and obtain the normalized value of sharing.

[0027] The location index of each resource module is obtained from the topological sorting sequence, and the inverse value of the location is calculated based on the location index; the location index is constructed using a counting method starting from zero.

[0028] Based on the sharing degree weight coefficient and the topology location weight coefficient, the normalized value of sharing degree and the inverse value of location are weighted and summed to obtain the priority score of each unloaded resource module; where the sum of the sharing degree weight coefficient and the topology location weight coefficient is 1.

[0029] Multiply the product of the current network bandwidth and the estimated user dwell time by the preset bandwidth occupancy coefficient to obtain the bandwidth adaptation capacity, obtain the preset upper limit of the preloaded absolute capacity, and take the smaller value between the bandwidth adaptation capacity and the upper limit of the preloaded absolute capacity as the upper limit of the preloaded capacity.

[0030] The unloaded resource modules in the second category of candidate resources are sorted from high to low according to their priority scores to obtain the sorted unloaded resource modules;

[0031] Initialize the total selected volume to zero, then iterate through the sorted unloaded resource modules one by one, and add the volume of the currently iterated resource module to the total selected volume to obtain the accumulated volume;

[0032] If the accumulated volume does not exceed the preload capacity limit, the corresponding resource module is added to the second preload candidate set, and the selected total volume is updated to the accumulated volume; if the accumulated volume exceeds the preload capacity limit, the traversal operation is terminated, and the final second preload candidate set is obtained.

[0033] In one embodiment, the method further includes:

[0034] The state at each preloading decision moment is set as a feature vector. The feature vector includes the current user behavior intent vector, the cache existence flag vector of each resource node in the resource dependency graph, the current network bandwidth, the current round-trip latency, and the current page path.

[0035] The action is set as a binary vector, which is used to represent the selection result of selecting a subset of each resource module to perform resource preloading operation;

[0036] The reward function is set as the preload hit reward minus the bandwidth cost penalty plus the latency improvement reward. The preload hit reward is calculated based on the actual number of preloaded resources used and the number of unused preloaded resources. The bandwidth cost penalty is calculated based on the total number of preloaded bytes. The latency improvement reward is calculated based on the baseline time without preload and the actual first screen rendering time.

[0037] Construct a policy network that shares underlying parameters with the graph attention network. The policy network takes the resource dependency graph and the user behavior intent vector as input and outputs the policy score and state value estimate of each resource module.

[0038] The system acquires a four-tuple log of the actual operation process, including the state, actions, rewards, and the next state. The rewards are calculated using a reward function based on the actual number of preloaded resources used, the number of unused preloaded resources, the total number of preloaded bytes, the baseline time without preloading, and the actual first-screen rendering time. The next state is constructed by collecting the new user behavior intent vector, the cache presence flag vector of each resource node, the new network bandwidth, the new round-trip latency, and the new page path after the resource preloading operation is executed, according to the feature vector construction rules.

[0039] Based on the quadruplet log, the parameters of the policy network are updated using the near-end policy optimization algorithm to obtain the updated policy network parameters;

[0040] The updated graph attention network is obtained by replacing the output layer parameters of the graph attention network with the updated policy network parameters. The updated graph attention network is used as the computing network for the next round to calculate the user behavior intent vector for the next round and output the policy score of each resource module. The policy score is used to replace the access probability and S3-S5 are repeated.

[0041] In one embodiment, the confidence level is calculated through the following steps:

[0042] The predicted entropy value of each resource module is calculated based on the probability of being accessed;

[0043] The difference between 1 and the predicted entropy value is defined as the confidence level.

[0044] In one embodiment, the preload capacity limit is calculated using the following formula:

[0045]

[0046] in, This indicates the upper limit of the preload capacity; This indicates the current network bandwidth; This indicates the estimated user dwell time; This represents the preset bandwidth utilization factor, with a value range of [value range missing]. ; Indicates the current network round-trip latency; Indicates the round-trip delay threshold; Indicates recent Variance of sub-bandwidth sampling ; Represents the minimum value, taking values ​​of This is used to avoid calculation errors where the denominator is zero; Indicates the maximum absolute capacity for preloading; This represents the failure compensation coefficient, with a value range of [value range missing]. ; This indicates the historical preloading failure rate.

[0047] Secondly, this application also provides a website static resource dynamic loading system, including:

[0048] The graph construction module is used to perform static analysis on multiple static resource modules of the target website, extract the static attributes of each resource module, and construct a resource dependency graph; perform topological sorting on the resource dependency graph to obtain a topological sorting sequence, and calculate the sharing score of each resource module based on the resource dependency graph; static attributes include key tags on the first screen;

[0049] The perception and prediction module is used to collect heterogeneous user behavior sequences in real time, perform temporal modeling on the heterogeneous behavior sequences through a behavior feature encoder, and generate user behavior intent vectors. The resource dependency graph and user behavior intent vectors are input into a graph attention network to output the access probability of each resource module. The heterogeneous behavior sequences include discrete behavior events, continuous behavior metrics, and contextual state features.

[0050] The high confidence filtering module is used to calculate the confidence of each resource module based on the access probability, and to select resource modules with a confidence of not less than a preset confidence threshold as the first type of candidate resources. The resources are then filtered according to the access probability of the first type of candidate resources to obtain the first preloaded candidate set.

[0051] The capacity-constrained loading module is used to select resource modules with confidence scores below a preset confidence threshold as second-class candidate resources, trigger the topology-preserving loading strategy, calculate the upper limit of preloading capacity based on the current network bandwidth and estimated user dwell time, extract unloaded resource modules from the second-class candidate resources from the topology sorting sequence, calculate the priority score of each unloaded resource module, and select unloaded resource modules in descending order of priority score to add them to the second preloading candidate set until the total volume of the second preloading candidate set reaches the upper limit of preloading capacity, thus obtaining the final second preloading candidate set;

[0052] The preloading execution module is used to merge the first preloading candidate set with the final second preloading candidate set to obtain the final preloading resource set; based on the first screen key tags of each resource module in the final preloading resource set, preloading instructions are configured. The preloading instructions are used to instruct the creation of corresponding link tags in reverse order of the topological sorting sequence, and insert the link tags into the HTML document head to perform resource preloading operations.

[0053] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the first aspect.

[0054] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the first aspect.

[0055] The aforementioned website's static resource dynamic loading method, system, device, and medium first construct a resource dependency graph and calculate a sharing score through static analysis and topological sorting, solving the problems of coarse dependency resolution, chaotic resource priority, and abnormal circular dependencies in traditional loading methods, thus achieving refined modeling of the resource structure. Second, it performs temporal modeling through a behavioral feature encoder and combines it with a graph attention network to predict resource access probabilities, overcoming the limitations of single-behavior perception and achieving the characterization of user intent and prediction of resource access. Furthermore, it filters high-confidence resources based on confidence thresholds and loads low-confidence resources in a capacity-constrained, order-preserving manner, balancing preloading hit rate and bandwidth utilization, avoiding overloading of unnecessary resources and bandwidth waste in cold start scenarios. Finally, it configures preloading instructions through key tags on the first screen and injects them into the HTML header in reverse topological order for loading, ensuring the priority readiness of key resources and the correct resolution of dependencies, enhancing first-screen rendering speed, page switching smoothness, and adaptive loading capabilities in dynamic network environments. Attached Figure Description

[0056] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0057] Figure 1 A flowchart of a method for dynamically loading static resources on a website, provided as an exemplary embodiment of the present invention;

[0058] Figure 2 A flowchart illustrating a method for outputting the access probability of each resource module through a graph attention network, as provided in an exemplary embodiment of the present invention;

[0059] Figure 3 This is a schematic diagram of a website static resource dynamic loading system structure provided as an exemplary embodiment of the present invention. Detailed Implementation

[0060] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0061] In one embodiment, such as Figure 1 As shown, a method for dynamically loading static resources on a website is provided. This embodiment illustrates the application of this method to a terminal. It is understood that this method can also be applied to a server, and to a system including both a terminal and a server, and is implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0062] S1. Perform static analysis on multiple static resource modules of the target website, extract the static attributes of each resource module, and construct a resource dependency graph; perform topological sorting on the resource dependency graph to obtain the topological sorting sequence, and calculate the sharing score of each resource module based on the resource dependency graph; static attributes include key tags on the first screen.

[0063] Specifically, static resource modules include, but are not limited to, JavaScript files, CSS style files, image resources, font files, and static page fragments. Through static analysis of these modules, their static attributes can be systematically extracted, such as identifiers, sizes, key tags for the first screen, and functional module tags. Key tags for the first screen can be used to distinguish whether a resource is necessary for the initial rendering of the page, providing a basis for preloading instruction configuration. Furthermore, direct and indirect references between resource modules can be resolved. Using resource modules as nodes and reference relationships as directed edges, a resource dependency graph can be constructed. This graph clearly presents the dependency topology between resources, avoiding rendering blockages caused by missing dependencies during loading. Topological sorting of the resource dependency graph yields a topological sort sequence without circular dependencies. This sequence provides the basic logic for the subsequent loading order, ensuring a reasonable order of loading upstream resources first and downstream resources later. By traversing the resource dependency graph in reverse, we can count the number of times each resource module is referenced by other functional modules, and calculate the sharing score of each resource module. The higher the sharing score, the stronger the reuse value of the resource. This score can provide a quantitative basis for resource priority judgment in subsequent low-confidence scenarios.

[0064] S2. Collect heterogeneous user behavior sequences in real time, perform temporal modeling on the heterogeneous behavior sequences through a behavior feature encoder, and generate user behavior intent vectors; input the resource dependency graph and user behavior intent vectors into a graph attention network, and output the access probability of each resource module; wherein, the heterogeneous behavior sequences include discrete behavior events, continuous behavior metrics and context state features.

[0065] Specifically, discrete behavioral events in a heterogeneous behavioral sequence can include clicks, page scrolling, and button triggers, while continuous behavioral metrics can include scrolling speed, dwell time, and operation frequency. Contextual state features can include device type, network type, current page path, and browser version. This sequence allows for the comprehensive capture of user behavior characteristics and access scenarios from multiple dimensions. Subsequently, a heterogeneous behavioral feature encoder performs temporal modeling on this sequence, uncovering the correlation patterns of behavioral events over time, such as the logic of a user scrolling the page before clicking a specific button. This transforms dynamic, heterogeneous behavioral data into a fixed-dimensional user behavior intent vector, achieving the structuring of behavioral features. This user behavior intent vector provides subjective access preferences, while the resource dependency graph provides objective correlation logic between resources. By inputting both the resource dependency graph and the user behavior intent vector into a graph attention network, the advantages of graph attention networks in processing graph structured data can be further utilized. This integrates the topological dependency features of resources with the personalized intent features of users. Through feature propagation and probability calculation, the probability of each resource module being accessed under the current user behavior intent is output, providing a quantitative basis for subsequent pre-loading resource selection.

[0066] S3. Calculate the confidence level of each resource module based on the access probability, and select the resource modules with a confidence level not lower than the preset confidence threshold as the first type of candidate resources. Filter resources according to the access probability of the first type of candidate resources to obtain the first preloaded candidate set.

[0067] Specifically, the closer the access probability is to 0 or 1, the clearer the prediction result and the higher the confidence level. However, when the probability is close to 0.5, the greater the prediction uncertainty and the lower the confidence level. Therefore, resource modules with a confidence level not lower than a preset confidence threshold can be considered as the first type of candidate resources. This is because the access prediction results of these resources are highly reliable. By comparing their access probability with the preset probability threshold, if the access probability is greater than the threshold, it means that the user is likely to access the resource. Therefore, resources with an access probability greater than the threshold can be included in the first preloading candidate set, avoiding invalid preloading of low-probability resources, thereby improving the preloading hit rate and reducing bandwidth resource waste.

[0068] S4. Resource modules with confidence levels lower than the preset confidence threshold are designated as second-class candidate resources. The topology order-preserving loading strategy is triggered. The upper limit of the preload capacity is calculated based on the current network bandwidth and the estimated user dwell time. Unloaded resource modules are extracted from the second-class candidate resources from the topology sorting sequence. The priority score of each unloaded resource module is calculated. Unloaded resource modules are selected in descending order of priority score and added to the second preload candidate set until the total volume of the second preload candidate set reaches the upper limit of the preload capacity, thus obtaining the final second preload candidate set.

[0069] Specifically, for the second category of candidate resources with a confidence level below a preset confidence threshold, since the access status of such resources cannot be accurately determined by a single probability value, a topology-preserving loading strategy can be triggered. This strategy combines the objective attributes of the resources with the current network and user status to make a comprehensive decision, addressing preloading decision-making issues in scenarios with predictive uncertainty, such as cold starts in user behavior or sudden changes in access paths. For example, since the total amount of preloaded resources is limited by network transmission capacity and user dwell time, exceeding this limit can lead to bandwidth congestion or resource failure before use. Therefore, the preload capacity limit can be calculated first based on the current network bandwidth and estimated user dwell time. Subsequently, unloaded resource modules can be extracted from the topology sorting sequence and priority scores can be calculated. By integrating resource sharing (reuse value) and topology location (dependency priority), it can be ensured that highly reusable and critical resources are loaded first under limited capacity. Resources are selected from high to low priority scores until the capacity limit is reached, resulting in a second preloaded candidate set. This ensures the topological rationality of resource loading and maximizes the potential use value of preloaded resources, avoiding the problem of traditional fixed-rule preloading being out of touch with actual scenarios.

[0070] S5. Merge the first preload candidate set with the final second preload candidate set to obtain the final preload resource set; configure preload instructions based on the first screen key tags of each resource module in the final preload resource set. The preload instructions are used to instruct the creation of corresponding link tags in reverse order of the topological sorting sequence, and insert the link tags into the HTML document head to perform resource preload operation.

[0071] Specifically, by merging the first and second preloading candidate sets, coverage of both highly reliable predicted resources and high-potential-value resources can be achieved. Since the resources required for the initial screen rendering directly impact the user's initial access experience, preloading instructions can be configured based on the key tags of each resource module's initial screen. This prioritizes caching resources in advance using preloading instructions, while non-initial-screen resources are processed according to conventional preloading logic, achieving a balance between initial screen experience and overall loading efficiency. Furthermore, the reverse order of the topological sorting sequence corresponds to the downstream-to-upstream order of resource dependencies. Therefore, link tags can be created in reverse order of the topological sorting sequence and inserted into the HTML document header to ensure no dependency loss occurs during preloading. Inserting link tags into the HTML document header allows the browser to parse and execute preloading instructions first, initiating resource download and caching in advance and avoiding resource blocking during page rendering. Through this process, dynamic adaptive preloading of static resources can ultimately be achieved, effectively improving resource loading efficiency, reducing bandwidth waste, improving website access smoothness, and solving the balance problem between prediction accuracy, scenario adaptability, and resource utilization in existing loading solutions.

[0072] The above method first constructs a resource dependency graph and calculates sharing scores through static analysis, clarifying resource dependencies and loading priorities, thus solving the problems of coarse resource dependency parsing and disordered loading order, and laying a topological foundation for dynamic loading. Second, it collects heterogeneous behavior sequences and combines them with a graph attention network to output the probability of resource access, fusing user behavioral intent and resource structure features, solving the problems of singular user intent perception and inaccurate resource access prediction. Furthermore, it divides candidate resources based on confidence and triggers a topology-preserving loading strategy, which can balance high-confidence prediction decisions with cold-start scenario adaptation, avoiding bandwidth waste and preloading failure. Finally, it merges the preloading candidate sets and executes preloading in reverse topological order, optimizing the resource loading order and instruction configuration, improving the efficiency of static resource loading and cache utilization.

[0073] In one embodiment, the behavior feature encoder includes a type-aware embedding layer, a temporal coding layer, and an intent output layer. The type-aware embedding layer includes a discrete event embedding matrix, a continuous metric projection linear layer, a context projection linear layer, and a splicing compression linear layer. The temporal coding layer is a multi-layer Transformer encoder.

[0074] The behavioral feature encoder is trained through the following steps:

[0075] Obtain discrete behavioral events, continuous behavioral metrics, and contextual state features from historical user sessions, align them by timestamps, and generate historical heterogeneous behavior sequences.

[0076] The actual resource accesses that occurred in the historical user sessions corresponding to each historical heterogeneous behavior sequence are used as supervision labels;

[0077] The trainable parameters of the behavior feature encoder are pre-trained using the cross-entropy loss function to obtain the trained behavior feature encoder. The trainable parameters include the discrete event embedding matrix, the continuous metric projection linear layer, the context projection linear layer, the concatenation compression linear layer, the parameters of the Transformer encoder, and the linear transformation parameters of the intent output layer.

[0078] Specifically, the type-aware embedding layer can be used to transform discrete behavioral events, continuous behavioral metrics, and contextual state features into embedding vectors with uniform dimensions. The discrete event embedding matrix can be used to semantically map discrete behavioral events. The number of rows in this matrix equals the total number of categories of discrete behavioral events, and the number of columns is the preset embedding dimension. Each discrete behavioral event category corresponds to one row vector in the matrix. For example, the embedding calculation of discrete behavioral events can be represented as... , For discrete behavioral events, Embedding matrix for discrete events, This is a one-hot encoded vector corresponding to a discrete behavioral event. In the one-hot encoded vector, only the position corresponding to the behavioral event category is 1, and the rest are 0. Through this calculation, discrete category information can be transformed into a low-dimensional dense vector representation.

[0079] Specifically, the continuous metric projection linear layer can be used to perform dimensionality adaptation and linear transformation on continuous behavioral metrics. Since the numerical range of continuous behavioral metrics may vary significantly, they can be normalized before being input into this linear layer. The continuous metric projection linear layer can map the normalized continuous behavioral metrics to the same dimension as the discrete behavioral event embedding vector using a trainable weight matrix and bias vector. Its calculation process is as follows: , The projection vector of the continuous behavior metric. The weight matrix of the continuous metric projected linear layer. This is the normalized continuous behavior metric vector. The bias vector of this linear layer is optimized through training. and This allows continuous features to be integrated with discrete features in the same vector space.

[0080] Indicatively, context state features typically contain multi-dimensional information such as device type, network type, and current page path. Some are discrete categorical, while others are low-dimensional continuous. Therefore, they can be uniformly encoded using a context projection linear layer. For example, for the discrete parts of the context state features, one-hot encoding is performed first, while the continuous parts retain their original values ​​and are normalized. The processed context features are then concatenated into a unified vector, which is input into the context projection linear layer for dimensionality transformation and feature extraction to obtain the context projection vector. This allows for the structured representation of contextual features through linear transformation, making them suitable for subsequent fusion processes.

[0081] Specifically, the concatenated compressed linear layer is used to embed discrete behavioral events into a vector. Continuous behavior metric projection vector and context projection vector Feature fusion involves concatenating the three features along their respective dimensions to form a high-dimensional joint feature vector. Since the high dimensionality of the concatenated features can lead to increased computational complexity, a linear layer is used to compress and non-linearly transform the high-dimensional joint features, outputting a fused feature vector with uniform dimensions. This linear layer includes a weight matrix, a bias vector, and an activation function. The ReLU function is used to introduce non-linear feature interactions.

[0082] Specifically, the temporal coding layer can employ a multi-layer Transformer encoder. Each Transformer encoder layer contains a multi-head self-attention sub-layer and a feedforward neural network sub-layer. Layer normalization and dropout layers are placed before and after each sub-layer. Layer normalization stabilizes gradient flow during training, while dropout randomly discards some features to prevent overfitting. The multi-head self-attention sub-layer can capture the temporal correlation of behavioral sequences from different perspectives by computing multiple attention heads in parallel. Each attention head independently calculates the query vector, key vector, and value vector of the input features. Attention weights are calculated based on the similarity between the query vector and the key vector. The value vectors are then weighted and summed based on these attention weights to obtain the output of that attention head. The outputs of all attention heads are then concatenated, and a linear transformation is used to obtain the final output of the multi-head self-attention sub-layer. The feedforward neural network sub-layer can contain two linear transformation layers and an intermediate ReLU activation function to further extract features and perform non-linear transformations on the output of the multi-head self-attention sub-layer, enhancing the model's expressive power.

[0083] Through the aforementioned multi-layer Transformer encoder, deep modeling of the temporal dependencies of behavioral sequences can be achieved by stacking layers one by one. High-level semantic features are gradually extracted from low-level temporal features, providing feature inputs rich in temporal information for the intent output layer. This intent output layer can be a single-layer linear transformation layer to map the high-level temporal features output by the temporal encoding layer into a fixed-dimensional user behavior intent vector. The dimension of the output vector can be set according to the actual application scenario.

[0084] Based on the above structure, the behavior feature encoder can first acquire discrete behavior events, continuous behavior metrics, and contextual state features from historical user sessions. The collected data can be preprocessed, such as data cleaning and format standardization, removing abnormal behavior data, unifying data from different sources into a preset data format, and clarifying the definition and value range of each feature field. Subsequently, features are aligned by timestamp; that is, for the same user's behavior data, it is arranged in ascending order of timestamp to form an ordered behavior sequence. If multiple behavior events exist at the same timestamp, they can be arranged sequentially according to the order in which the behaviors occurred. For missing values ​​in continuous behavior metrics, the mean of similar behaviors for that user is used to fill in the gaps. For missing values ​​in discrete behavior events and contextual state features, preset special symbols can be used to mark them, ultimately generating a historical heterogeneous behavior sequence.

[0085] Furthermore, for each historical heterogeneous behavior sequence, a set of resource modules actually accessed by the user within a preset time window after the end of the sequence (the length of which is set according to the average user dwell time on the website) can be extracted to construct a binary label vector. The dimension of the label vector is consistent with the total number of resource modules on the target website. If a user accesses a certain resource module, the element at the corresponding position in the label vector is 1; otherwise, it is 0. This label vector directly reflects the actual resource access situation of the user in the current behavior sequence, providing a supervision signal for model training.

[0086] Specifically, the trainable parameters of the behavior feature encoder can be pre-trained using the cross-entropy loss function. This cross-entropy loss function can effectively measure the difference between the model's prediction results and the supervision labels. Its calculation formula is as follows:

[0087]

[0088] in, This represents the cross-entropy loss value. This represents the number of samples in the training batch (i.e., the number of historical heterogeneous behavior sequences). This represents the total number of resource modules. For the first The supervision label vector corresponding to the nth sample The value of each element (0 or 1), For the behavior feature encoder to the first The predicted number of samples The access probability of each resource module. During training, trainable parameters include the discrete event embedding matrix, the weight matrix and bias vector of the continuous metric projection linear layer, the weight matrix and bias vector of the context projection linear layer, the weight matrix, bias vector and activation function parameters of the concatenated compressed linear layer, all parameters of the Transformer encoder, and the linear transformation weight matrix and bias vector of the intent output layer.

[0089] Subsequently, for the aforementioned parameters, stochastic gradient descent or adaptive moment estimation optimization algorithms can be used for training. Appropriate learning rates, batch sizes, and training epochs should be set. The learning rate can be dynamically adjusted using a cosine annealing strategy to avoid gradient vanishing or oscillations during training. The batch size can be set according to hardware computing resources, and model performance can be monitored using a validation set. Training can be stopped when the loss value on the validation set no longer decreases for a preset number of epochs to prevent overfitting. After training, the optimal values ​​of all trainable parameters are saved, resulting in a behavioral feature encoder that accurately captures the temporal patterns of user behavior and resource access intentions. This encoder can be directly used in real-time scenarios to perform temporal modeling of heterogeneous user behavior sequences and generate high-quality user behavior intention vectors.

[0090] In one embodiment, a graph attention network may include a feature construction layer, multiple attention propagation layers, and an output layer. The feature construction layer transforms the unstructured attributes and state information of resource modules into numerical feature vectors suitable for deep learning and initializes the weight parameters required for network propagation. The multiple attention propagation layers, through iterative feature propagation and attention calculation, integrate resource dependencies, resource characteristics, and user intent, with each layer capturing more complex dependency relationships and intent matching patterns. The output layer maps the comprehensive feature vector obtained through multiple propagations to probability values ​​between 0 and 1, yielding the probability of being accessed.

[0091] Indicative, such as Figure 2 As shown, the resource dependency graph and user behavior intent vector are input into the graph attention network, and the output probability of each resource module being accessed can include:

[0092] S201: Obtain the loaded status of each resource module. Through the feature construction layer, construct the initial feature vector of each resource node based on the static attributes and loaded status of each resource module in the resource dependency graph. Learn the globally shared weight matrix based on the attention propagation layers of the graph attention network.

[0093] Specifically, the loaded state can be represented by a binary variable. A value of 1 indicates that the resource module has been loaded and cached, while a value of 0 indicates that the resource module has not been loaded and cached. This state information can be collected in real time by the website's resource loading monitoring module and synchronized to the graph attention network. When constructing the initial feature vector for each resource node through the feature construction layer, the static attributes of each resource module in the resource dependency graph can be structured first. These static attributes include the resource module's volume, sharing score, and first-screen key labels. The first-screen key labels are converted into binary features, and the volume and sharing score are standardized to ensure that the values ​​of each attribute are on the same order of magnitude. Subsequently, the processed static attributes and the loaded state features are concatenated in dimensionality to form an initial feature vector. This vector encompasses the objective attributes of the resource module and the current loading state information. Furthermore, parameter initialization and preliminary learning can be performed based on the attention propagation layers of the graph attention network to obtain a globally shared weight matrix. This weight matrix is ​​used for the linear transformation of features in subsequent layers, and its dimension is determined by the dimension of the input feature vector and the preset hidden layer feature dimension.

[0094] S202: The features of each resource node in the current layer are linearly transformed by the weight matrix to obtain the transformed features; where, when the current layer is the first attention propagation layer, the features of each resource node in the current layer are the corresponding initial feature vectors.

[0095] Specifically, through linear transformation, the features of the current layer can be mapped to a predefined hidden layer feature space, achieving feature dimension unification and semantic information enhancement. The formula for calculating the transformed features can be expressed as follows: ,in For the first Transformation characteristics of individual resource nodes The weight matrix is ​​shared globally. For the current layer The features of each resource node. In addition, if the current layer is the first attention propagation layer, the features of each resource node in the current layer are the initial feature vectors output by the feature construction layer. At this time, the linear transformation mainly realizes the dimensionality improvement and semantic encoding of the initial features. If the current layer is a subsequent attention propagation layer, the features of the current layer are the feature representations output by the previous attention propagation layer. The linear transformation is used to further optimize the feature expression and provide more effective feature input for subsequent attention calculation.

[0096] S203: For each directed edge in the resource dependency graph, define the edge pointing to the target node as the incoming edge, obtain the transformation features of the source node and the transformation features of the target node of the directed edge; perform a linear transformation on the user behavior intent vector through the intent projection matrix to obtain the intent projection vector.

[0097] Specifically, for each directed edge in the resource dependency graph, the source node and target node of the directed edge can be identified first. The source node is the starting resource module with a reference relationship, and the target node is the referenced resource module. The edge pointing to the target node in the directed edge is defined as an incoming edge, that is, the incoming edge represents the dependency support relationship between the source node and the target node. For each incoming edge, the transformation features of its source node and the transformation features of its target node can be extracted separately to ensure that the two features are in the same feature space. Furthermore, the user behavior intent vector can be linearly transformed by the intent projection matrix. This intent projection matrix is ​​a trainable parameter matrix, and its dimension is determined by the dimension of the user behavior intent vector and the dimension of the resource node transformation features. Through linear transformation, the user behavior intent vector can be mapped to the same dimensional space as the resource node transformation features, eliminating the fusion barrier caused by the difference in feature dimensions, and obtaining the intent projection vector. This vector can participate in the subsequent attention calculation in a unified dimensional form, realizing the accurate fusion of user intent and resource dependency relationship.

[0098] S204: Concatenate the transformation features of the source node, the transformation features of the target node, and the intention projection vector along the feature dimension to obtain a joint vector; perform a dot product operation on the joint vector and the preset attention parameter vector to obtain the dot product result; activate the dot product result through the LeakyReLU activation function to obtain the unnormalized attention score of the corresponding directed edge.

[0099] Specifically, the transformed features of the source node, the transformed features of the target node, and the intent projection vector are concatenated along the feature dimension, i.e., sequentially superimposed in feature order to form a high-dimensional joint vector. This joint vector simultaneously contains the features of the source node, the target node, and the user intent, comprehensively reflecting the correlation information between resource dependencies and user intent. The joint vector is then subjected to a dot product operation with a preset attention parameter vector, where the attention parameter vector is a trainable one-dimensional vector with the same length as the joint vector. The dot product operation is used to calculate the similarity between the joint vector and the attention parameter vector; a higher similarity indicates a greater influence of the corresponding feature combination on attention allocation. The dot product result is then activated using the LeakyReLU activation function. The LeakyReLU activation function can retain positive feature responses while assigning smaller gradient values ​​to negative features, avoiding the gradient vanishing problem, and can capture richer feature interaction patterns. After activation, the unnormalized attention score of the corresponding directed edge is obtained, which intuitively reflects the importance of the current directed edge in matching resource dependencies and user intent.

[0100] S205: Normalize the unnormalized attention scores of each incoming edge of each target node to obtain the normalized attention coefficients of each incoming edge; use the normalized attention coefficients to perform a weighted summation of the transformation features of the target node's neighboring nodes to obtain the feature representation of the target node at the next layer.

[0101] Specifically, the unnormalized attention scores of each incoming edge of the target node can be normalized using the Softmax function. After normalization, the sum of the attention coefficients of all incoming edges of each target node is 1, ensuring the interpretability and additivity of the attention weights. By normalizing the attention coefficients, the transformation features of the target node's neighboring nodes can be weighted and summed, where neighboring nodes are the source nodes corresponding to all incoming edges of the target node. During the weighted summation process, by multiplying the transformation feature of each neighboring node by its corresponding attention coefficient and then accumulating the results, the next-layer feature representation of the target node can be obtained. This feature representation integrates the important information of the neighboring nodes and the characteristics of the target node itself, achieving effective transfer of resource dependencies and feature enhancement.

[0102] S206: Use the feature representation of the next layer of the target node as the feature of the current layer processed by the next attention propagation layer, repeat S202 to S205, and perform multi-layer feature propagation. When the propagation reaches the preset last layer, the final feature representation of each resource node is obtained. Input the final feature representation of each resource node into the output layer, perform Sigmoid activation, and obtain the access probability of each resource module.

[0103] Specifically, the feature representation of the next layer of the target node is used as the feature of the current layer processed by the next attention propagation layer. The linear transformation, attention score calculation, normalization, and weighted summation operations from S202 to S205 can be repeatedly executed to perform multi-layer feature propagation. Through multi-layer propagation, deep correlation information in the resource dependency graph can be gradually mined. Each layer of propagation can further integrate broader neighbor node information and user intent based on the fused features of the previous layer, making the final feature representation more representative. When propagation reaches the preset last layer, feature propagation stops. The features of each resource node obtained at this point are the final feature representation, which comprehensively integrates the resource's own attributes, the entire graph's dependencies, and the user's behavioral intent. The final feature representation of each resource node is input to the output layer, which is a single-layer linear transformation layer. This linear transformation maps the final feature representation to a one-dimensional vector, followed by Sigmoid activation, compressing the input values ​​to the range of 0 to 1. This yields the access probability of each resource module. The closer the probability value is to 1, the greater the likelihood of the user accessing the resource module; the closer it is to 0, the lower the likelihood.

[0104] In one embodiment, the prediction uncertainty of the access probability calculated based on the above embodiments can be quantified to obtain a confidence level. The lower the prediction uncertainty, the higher the confidence level, and vice versa. For example, the prediction entropy value of each resource module can be calculated first based on the access probability, that is, the Bernoulli entropy calculation logic is used based on the access probability. Entropy is a classic indicator for measuring the uncertainty of random variables. Based on the access probability of a resource module, the corresponding prediction entropy value can be calculated using the following formula:

[0105]

[0106] in, For the first The predicted entropy value of each resource module. This represents the probability of this resource module being accessed. When the access probability is close to 0 or 1, the uncertainty of the prediction result is extremely low, and the entropy value approaches 0. However, when the access probability is close to 0.5, the uncertainty of the prediction result is the highest, and the entropy value reaches its maximum value. The difference between 1 and the predicted entropy value is defined as the confidence level. The formula for calculating the confidence level is as follows: , This represents the confidence level of the resource module. This definition allows the confidence level to correspond to the entropy value. When the entropy value approaches 0, the confidence level approaches 1, indicating extremely high reliability of the prediction result. When the entropy value reaches its maximum value, the confidence level approaches 0, indicating extremely low reliability of the prediction result. This achieves precise quantification of prediction reliability.

[0107] In one embodiment, the preload capacity limit is calculated based on the current network bandwidth and estimated user dwell time. Unloaded resource modules are extracted from the second type of candidate resources from the topology sorting sequence. The priority score of each unloaded resource module is calculated. Unloaded resource modules are selected in descending order of priority score and added to the second preload candidate set until the total volume of the second preload candidate set reaches the preload capacity limit, resulting in the final second preload candidate set, including:

[0108] Read the sharing score of each resource module from the resource dependency graph, obtain the maximum sharing of the entire graph in the resource dependency graph, calculate the ratio of each sharing score to the maximum sharing of the entire graph, and obtain the normalized value of sharing.

[0109] The location index of each resource module is obtained from the topological sorting sequence, and the inverse value of the location is calculated based on the location index; the location index is constructed using a counting method starting from zero.

[0110] Based on the sharing degree weight coefficient and the topology location weight coefficient, the normalized value of sharing degree and the inverse value of location are weighted and summed to obtain the priority score of each unloaded resource module; where the sum of the sharing degree weight coefficient and the topology location weight coefficient is 1.

[0111] Multiply the product of the current network bandwidth and the estimated user dwell time by the preset bandwidth occupancy coefficient to obtain the bandwidth adaptation capacity, obtain the preset upper limit of the preloaded absolute capacity, and take the smaller value between the bandwidth adaptation capacity and the upper limit of the preloaded absolute capacity as the upper limit of the preloaded capacity.

[0112] The unloaded resource modules in the second category of candidate resources are sorted from high to low according to their priority scores to obtain the sorted unloaded resource modules;

[0113] Initialize the total selected volume to zero, then iterate through the sorted unloaded resource modules one by one, and add the volume of the currently iterated resource module to the total selected volume to obtain the accumulated volume;

[0114] If the accumulated volume does not exceed the preload capacity limit, the corresponding resource module is added to the second preload candidate set, and the selected total volume is updated to the accumulated volume; if the accumulated volume exceeds the preload capacity limit, the traversal operation is terminated, and the final second preload candidate set is obtained.

[0115] Specifically, the sharing score of each resource module can be read from the resource dependency graph. This sharing score represents the number of times a resource module is referenced by other functional modules after deduplication, reflecting the reuse value of the resource. The higher the sharing score, the greater the likelihood that the resource is depended on by multiple modules, and the stronger its reuse value. The maximum sharing score across the entire resource dependency graph is obtained, which is the maximum value among all resource module sharing scores. The ratio of each resource module's sharing score to the maximum sharing score across the entire graph is calculated to obtain a normalized sharing value. This normalization process eliminates the magnitude differences in resource sharing scores between different websites, allowing for horizontal comparisons of the sharing levels of different resource modules.

[0116] Specifically, the position index of each resource module can be obtained from the topological sorting sequence. The position index is constructed using a zero-based counting method, meaning the position index of the first resource module in the topological sorting sequence is 0, the position index of the second resource module is 1, and so on. The inverse position value is calculated based on the position index. To avoid the calculation anomaly of a zero denominator when the position index is zero, the position index is incremented by one and the inverse is taken when calculating the inverse position value. The smaller the position index, the larger the corresponding inverse position value. This design gives higher position weights to resource modules that are earlier in the topological sorting sequence, reflecting the impact of the order of resources in the dependency chain on preloading priority, and ensuring that critical resources upstream are given priority.

[0117] Subsequently, based on the sharing degree weight coefficient and the topology position weight coefficient, a weighted sum of the normalized sharing degree value and the inverse position value can be performed. The sum of the sharing degree weight coefficient and the topology position weight coefficient is 1, which can be adjusted according to the resource dependency characteristics of different websites. The priority score of each unloaded resource module obtained through this process combines the reuse value of the resource with the importance of topology dependency. It considers both the potential use value of the resource being referenced by multiple modules and the order of the resource in the dependency chain, which can avoid the limitations of single-dimensional priority judgment and make the selection of preloaded resources more in line with actual loading needs.

[0118] As an illustration, the maximum preload capacity can be calculated using the following formula:

[0119]

[0120] in, Indicates the maximum preload capacity; This indicates the current network bandwidth, which can be collected in real time using the browser's built-in network performance API. This indicates the estimated user dwell time, which can be statistically predicted based on user historical session data or page access logs; This represents the preset bandwidth utilization factor, with a value range of [value range missing]. This is used to control the proportion of current bandwidth used by preloading operations, avoiding excessive bandwidth consumption by preloading that could affect normal page requests; RTT represents the current network round-trip time, reflecting the latency level of network transmission; This represents the round-trip delay threshold, which is an empirical value preset based on the target website service scenario, used to define the critical state of network transmission efficiency; Indicates recent The variance of sub-bandwidth sampling, where By calculating the variance of historical bandwidth sampling data, the fluctuation level of the current network bandwidth is reflected. The larger the variance, the worse the bandwidth stability. Represents the minimum value, taking values ​​of This is used to avoid calculation errors where the denominator is zero; This indicates the absolute upper limit of preload capacity, which is the preset upper limit of the total number of bytes of preloaded resources. It is used to limit the maximum resource size of the preload operation and prevent bandwidth waste caused by excessive preloading. This represents the failure compensation coefficient, with a value range of [value range missing]. This is used to control the capacity compensation magnitude based on historical failure rates; This indicates the historical preloading failure rate, which is the most recent. The ratio of the number of failures in a single preloading operation to the total number of preloading operations reflects the stability level of historical preloading operations.

[0121] The above formula takes the smaller value of the bandwidth-latency adaptation term and the failure compensation term as the upper limit of the preload capacity. The bandwidth-latency adaptation term takes into account the current network bandwidth, user dwell time, network round-trip latency and bandwidth fluctuation, and can dynamically adjust the preload capacity to adapt to the current network environment. The failure compensation term compensates the preload capacity based on the historical preload failure rate, which can improve the success rate of resource preload when the network environment is poor or the preload stability is insufficient, and avoid resource loss due to preload failure.

[0122] Specifically, the unloaded resource modules in the second category of candidate resources are sorted from highest to lowest priority score, resulting in a sorted sequence of unloaded resource modules. These unloaded modules are those not cached by the browser and not included in the first preload candidate set, ensuring that preloading is only planned for resources not yet ready in the current session. The total selected volume is initialized to zero. The sorted unloaded resource modules are then iterated through sequentially, with the volume of the currently iterated module added to the total selected volume. If the accumulated volume does not exceed the preload capacity limit, the corresponding resource module is added to the second preload candidate set, and the total selected volume is updated to the accumulated volume. If the accumulated volume exceeds the preload capacity limit, the iteration operation is terminated, resulting in the final second preload candidate set. This process, combining priority sorting with capacity constraints, prioritizes resource modules with high reuse value and critical topological positions within the limited preload capacity, maximizing the potential utilization efficiency of preloaded resources while avoiding loading blockages or resource failures caused by the total number of preloaded resources exceeding network capacity.

[0123] In one embodiment, the method further includes:

[0124] The state at each preloading decision moment is set as a feature vector. The feature vector includes the current user behavior intent vector, the cache existence flag vector of each resource node in the resource dependency graph, the current network bandwidth, the current round-trip latency, and the current page path.

[0125] The action is set as a binary vector, which is used to represent the selection result of selecting a subset of each resource module to perform resource preloading operation;

[0126] The reward function is set as the preload hit reward minus the bandwidth cost penalty plus the latency improvement reward. The preload hit reward is calculated based on the actual number of preloaded resources used and the number of unused preloaded resources. The bandwidth cost penalty is calculated based on the total number of preloaded bytes. The latency improvement reward is calculated based on the baseline time without preload and the actual first screen rendering time.

[0127] Construct a policy network that shares underlying parameters with the graph attention network. The policy network takes the resource dependency graph and the user behavior intent vector as input and outputs the policy score and state value estimate of each resource module.

[0128] The system acquires a four-tuple log of the actual operation process, including the state, actions, rewards, and the next state. The rewards are calculated using a reward function based on the actual number of preloaded resources used, the number of unused preloaded resources, the total number of preloaded bytes, the baseline time without preloading, and the actual first-screen rendering time. The next state is constructed by collecting the new user behavior intent vector, the cache presence flag vector of each resource node, the new network bandwidth, the new round-trip latency, and the new page path after the resource preloading operation is executed, according to the feature vector construction rules.

[0129] Based on the quadruplet log, the parameters of the policy network are updated using the near-end policy optimization algorithm to obtain the updated policy network parameters;

[0130] The updated graph attention network is obtained by replacing the output layer parameters of the graph attention network with the updated policy network parameters. The updated graph attention network is used as the computing network for the next round to calculate the user behavior intent vector for the next round and output the policy score of each resource module. The policy score is used to replace the access probability and S3-S5 are repeated.

[0131] Specifically, the state at each preloading decision moment is set as a feature vector. This feature vector is composed of multi-dimensional information fusion and can comprehensively represent the context of the current preloading decision. The user behavior intent vector is a fixed-dimensional dense vector obtained by modeling real-time heterogeneous user behavior sequences through a behavior feature encoder. The cache presence flag vector for each resource node in the resource dependency graph is a binary vector of the same length as the resource module list. Each element corresponds to a resource module; a value of 1 indicates that the resource module exists in the browser cache, and a value of 0 indicates that it is not cached. This vector can be generated in real-time by querying the browser cache status API. The current network bandwidth and current round-trip latency can be collected through the browser's built-in performance API, normalized, and mapped to a preset numerical range. The current page path is encoded into a fixed-dimensional vector using URL path information, and can be one-hot encoded or embedded in a vector format to ensure that the path information can be effectively recognized by the model. The above features are concatenated dimensionally to form the final state feature vector, providing state input for subsequent reinforcement learning decisions.

[0132] Specifically, actions can be set as binary vectors, with the dimension of the vector being the same as the total number of static resource modules on the target website. Each element corresponds to a resource module, with a value of 1 indicating that the resource module is selected to perform the preloading operation, and a value of 0 indicating that the preloading operation is not performed. The action vector can fully represent all possible selection results of selecting a preloading subset from all resource modules, providing a structured representation for the action space of reinforcement learning.

[0133] Specifically, the reward function can be set as the preloading hit reward minus the bandwidth cost penalty, plus the latency improvement reward. This reward function comprehensively evaluates the merits of preloading decisions from three dimensions: preloading effectiveness, resource cost, and user experience. Its calculation process can be expressed as follows:

[0134]

[0135] in, This represents the total reward value corresponding to this preload decision; This represents the weighting coefficient of the preloaded hit reward, used to control the proportion of the hit reward in the total reward; The preload hit reward is calculated based on the actual number of preloaded resources used and the number of unused preloaded resources. Specifically, it is calculated by subtracting the number of unused preloaded resources from the actual number of preloaded resources used and then dividing by the total number of preloaded resources. This ensures that the hit reward value is within a reasonable range and that the reward can directly reflect the actual utilization efficiency of preloaded resources. This represents the weighting coefficient for bandwidth cost penalties, used to control the intensity of the bandwidth cost penalty. This represents the sum of the sizes of all selected resource modules in this preloading operation, in bytes. This penalty is used to suppress bandwidth waste caused by excessive preloading. This represents the weighting coefficient for delayed improvement rewards, used to control the proportion of delayed improvement rewards; The latency improvement reward is calculated based on the difference between the baseline first-screen rendering time without preloading and the actual first-screen rendering time. The baseline time without preloading is the average first-screen rendering time in historical sessions when no preloading operation was performed. The larger the difference, the more significant the improvement effect of preloading on the first-screen rendering speed, and the higher the latency improvement reward.

[0136] Furthermore, a policy network sharing underlying parameters with the graph attention network can be constructed. This policy network adopts the same underlying feature extraction structure as the graph attention network, including a feature construction layer and multiple attention propagation layers. The shared underlying parameters can reuse the graph attention network's feature extraction capabilities for resource-dependent graph topology and user behavioral intent, avoiding redundant computation and reducing resource consumption during model training and inference. Based on the underlying feature representation, the policy network can set two independent output heads. The policy head is a single-layer linear transformation layer that maps the final feature representation of each resource node to a policy score vector. Each element corresponds to the preloaded policy score of a resource module, reflecting the priority of that resource module being preloaded. The value head can also be a single-layer linear transformation layer that aggregates the final feature representation of each resource node and maps it to a scalar state value estimate, representing the expected long-term reward of the preloaded decision in the current state, providing a foundation for calculating the advantage function in reinforcement learning.

[0137] Specifically, a four-tuple log of state, action, reward, and next state can be obtained during the actual operation. This log provides empirical data for training the reinforcement learning model. The state is a feature vector constructed before the preloading decision is executed; the action is the binary vector corresponding to this preloading operation; and the reward is calculated using the aforementioned reward function. During the calculation, the actual number of preloaded resources used, the number of unused preloaded resources, the total number of preloaded bytes, and the actual first-screen rendering time after the preloading operation are collected, and this is combined with a preset first-screen rendering time without preloading. The next state is a feature vector generated according to the state feature vector construction rules after the preloading operation is completed, based on the updated user behavior intent vector, cache presence flag vectors of each resource node, new network bandwidth and round-trip latency, and the new page path. The updated user behavior intent vector is a vector generated by the behavior feature encoder after the user behavior sequence is updated during preloading. The updated cache presence flag vector is a binary vector obtained by querying the browser cache status again after preloading, reflecting the impact of the preloading operation on the resource cache status.

[0138] Based on the collected quadruple logs, the parameters of the policy network can be updated using a proximal policy optimization algorithm. For example, the quadruple data can be batch-processed to construct training samples. Then, the state value estimate for each sample is calculated based on the current policy network, and the generalized advantage estimation method is used to calculate the advantage function. This advantage function reflects the degree of advantage of the current action relative to the average level, providing direction for policy updates. An objective function for proximal policy optimization is constructed, which includes a policy loss term and a value loss term. A pruning coefficient is set to limit the magnitude of policy updates, preventing excessive policy parameter updates from causing training instability. During training, an appropriate learning rate and batch size can be set, and gradient descent can be used to optimize the network parameters until the model converges, yielding the updated policy network parameters.

[0139] By replacing the output layer parameters of the graph attention network with those of the updated policy network, an updated graph attention network can be obtained. The updated graph attention network retains the original low-level feature extraction capabilities, while the output layer parameters are optimized through reinforcement learning to output policy scores for each resource module. These policy scores replace the original access probabilities, and the subsequent preloading resource selection process can be executed based on these policy scores. The preloading candidate set construction and preloading operations are repeated to form a closed loop of continuous optimization, enabling the preloading strategy to continuously adapt to changes in user behavior and network environment fluctuations, thereby improving the long-term preloading hit rate, resource utilization efficiency, and user access experience.

[0140] Based on the same inventive concept, this application also provides a website static resource dynamic loading system for implementing the website static resource dynamic loading method described above. The solution provided by this system is similar to the solution described in the above method; therefore, the specific limitations in one or more embodiments of the website static resource dynamic loading system provided below can be found in the limitations of the website static resource dynamic loading method described above, and will not be repeated here.

[0141] In one exemplary embodiment, such as Figure 3 As shown, a website static resource dynamic loading system 300 is provided, including:

[0142] The graph construction module 301 is used to perform static analysis on multiple static resource modules of the target website, extract the static attributes of each resource module, construct a resource dependency graph, perform topological sorting on the resource dependency graph to obtain a topological sorting sequence, and calculate the sharing score of each resource module based on the resource dependency graph; the static attributes include the first screen key tags;

[0143] The perception and prediction module 302 is used to collect heterogeneous behavior sequences of users in real time, perform temporal modeling on the heterogeneous behavior sequences through a behavior feature encoder, and generate user behavior intent vectors; input the resource dependency graph and user behavior intent vectors into a graph attention network, and output the access probability of each resource module; wherein, the heterogeneous behavior sequence includes discrete behavior events, continuous behavior metrics and context state features.

[0144] The high confidence screening module 303 is used to calculate the confidence of each resource module based on the access probability, and to select resource modules with a confidence of not less than a preset confidence threshold as the first type of candidate resources. The resources are screened according to the access probability of the first type of candidate resources to obtain the first preloaded candidate set.

[0145] The capacity-limited loading module 304 is used to select resource modules with confidence scores lower than a preset confidence threshold as second-class candidate resources, trigger the topology order-preserving loading strategy, calculate the upper limit of preloading capacity based on the current network bandwidth and the estimated user dwell time, extract unloaded resource modules from the second-class candidate resources from the topology sorting sequence, calculate the priority score of each unloaded resource module, and select unloaded resource modules in order of priority scores from high to low to add them to the second preloading candidate set until the total volume of the second preloading candidate set reaches the upper limit of preloading capacity, thus obtaining the final second preloading candidate set;

[0146] The preloading execution module 305 is used to merge the first preloading candidate set with the final second preloading candidate set to obtain the final preloading resource set; based on the first screen key tags of each resource module in the final preloading resource set, preloading instructions are configured. The preloading instructions are used to instruct the creation of corresponding link tags in reverse order of the topological sorting sequence, and insert the link tags into the HTML document header to perform resource preloading operations.

[0147] In one exemplary embodiment, the present invention also provides a computer device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the static resource dynamic loading method of this application website. A multi-core processor is preferred to improve the system's parallel processing capability. The memory provides sufficient temporary storage space to support program execution and data processing. The memory capacity should be large enough to accommodate large amounts of data and computational tasks.

[0148] In one exemplary embodiment, the present invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the website static resource dynamic loading method of this application. The computer-readable storage medium may include: a read-only memory, a random access memory, a solid-state drive, or an optical disk, etc.

[0149] The above-described embodiments are merely illustrative of several implementation methods of the embodiments of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the patent scope of the embodiments of this application. It should be noted that those skilled in the art can make several modifications and improvements without departing from the concept of the embodiments of this application, and these all fall within the protection scope of the embodiments of this application.

Claims

1. A method for dynamically loading static resources on a website, characterized in that, The method includes: S1. Perform static analysis on multiple static resource modules of the target website, extract the static attributes of each resource module, and construct a resource dependency graph; perform topological sorting on the resource dependency graph to obtain a topological sorting sequence, and calculate the sharing score of each resource module based on the resource dependency graph; the static attributes include key tags on the first screen; S2. Collect heterogeneous behavior sequences of users in real time, perform temporal modeling on the heterogeneous behavior sequences through a behavior feature encoder, and generate user behavior intent vectors; input the resource dependency graph and the user behavior intent vectors into a graph attention network, and output the access probability of each resource module; wherein, the heterogeneous behavior sequences include discrete behavior events, continuous behavior metrics, and context state features; S3. Calculate the confidence level of each resource module based on the access probability, and take the resource modules with confidence levels not lower than the preset confidence threshold as the first type of candidate resources. Perform resource filtering according to the access probability of the first type of candidate resources to obtain the first preloaded candidate set. S4. The resource modules with confidence levels lower than the preset confidence threshold are designated as the second type of candidate resources. The topology order-preserving loading strategy is triggered. The upper limit of the preloading capacity is calculated based on the current network bandwidth and the estimated user dwell time. Unloaded resource modules are extracted from the second type of candidate resources from the topology sorting sequence. The priority score of each unloaded resource module is calculated. The unloaded resource modules are selected in descending order of the priority score and added to the second preloading candidate set until the total volume of the second preloading candidate set reaches the upper limit of the preloading capacity, thus obtaining the final second preloading candidate set. S5. Merge the first preload candidate set with the final second preload candidate set to obtain the final preload resource set; configure preload instructions based on the first screen key tags of each resource module in the final preload resource set. The preload instructions are used to instruct the creation of corresponding link tags in reverse order of the topological sorting sequence, and insert the link tags into the HTML document header to perform resource preload operation.

2. The method according to claim 1, characterized in that, The behavior feature encoder includes a type-aware embedding layer, a temporal coding layer, and an intent output layer. The type-aware embedding layer includes a discrete event embedding matrix, a continuous metric projection linear layer, a context projection linear layer, and a splicing compression linear layer. The temporal coding layer is a multi-layer Transformer encoder. The behavioral feature encoder is trained through the following steps: Obtain discrete behavioral events, continuous behavioral metrics, and contextual state features from historical user sessions, align them by timestamps, and generate historical heterogeneous behavior sequences. The actual resource accesses that occurred in the historical user sessions corresponding to each of the aforementioned heterogeneous behavior sequences are used as supervision labels; The trainable parameters of the behavior feature encoder are pre-trained using the cross-entropy loss function to obtain the trained behavior feature encoder. The trainable parameters include the discrete event embedding matrix, the continuous metric projection linear layer, the context projection linear layer, the splicing compression linear layer, the parameters of the Transformer encoder, and the linear transformation parameters of the intent output layer.

3. The method according to claim 1, characterized in that, The graph attention network includes a feature construction layer, multiple attention propagation layers, and an output layer. The step of inputting the resource dependency graph and the user behavior intent vector into a graph attention network and outputting the access probability of each resource module includes: S201: Obtain the loaded status of each resource module; construct an initial feature vector for each resource node based on the static attributes and loaded status of each resource module in the resource dependency graph through the feature construction layer; learn based on each attention propagation layer of the graph attention network to obtain a globally shared weight matrix. S202: The features of each resource node in the current layer are linearly transformed using the weight matrix to obtain transformed features; wherein, when the current layer is the first attention propagation layer, the features of each resource node in the current layer are the corresponding initial feature vectors; S203: For each directed edge in the resource dependency graph, define the edge pointing to the target node as the incoming edge, obtain the transformation features of the source node and the transformation features of the target node of the directed edge; perform a linear transformation on the user behavior intent vector through the intent projection matrix to obtain the intent projection vector. S204: Concatenate the transformation features of the source node, the transformation features of the target node, and the intention projection vector along the feature dimension to obtain a joint vector; perform a dot product operation on the joint vector and a preset attention parameter vector to obtain a dot product result; activate the dot product result through the LeakyReLU activation function to obtain the unnormalized attention score corresponding to the directed edge. S205: Normalize the unnormalized attention scores of each incoming edge of each target node to obtain the normalized attention coefficients of each incoming edge; use the normalized attention coefficients to perform a weighted summation of the transformation features of the neighboring nodes of the target node to obtain the feature representation of the next layer of the target node. S206: The feature representation of the next layer of the target node is used as the feature of the current layer processed by the next attention propagation layer. S202 to S205 are repeated to perform multi-layer feature propagation. When the propagation reaches the preset last layer, the final feature representation of each resource node is obtained. The final feature representation of each resource node is input into the output layer and Sigmoid activation is performed to obtain the access probability of each resource module.

4. The method according to claim 1, characterized in that, The process involves calculating the preload capacity limit based on the current network bandwidth and estimated user dwell time, extracting unloaded resource modules from the second type of candidate resources from the topology sorting sequence, calculating the priority score of each unloaded resource module, and selecting unloaded resource modules in descending order of priority score to add them to the second preload candidate set until the total volume of the second preload candidate set reaches the preload capacity limit, thus obtaining the final second preload candidate set, including: Read the sharing score of each resource module from the resource dependency graph, obtain the maximum sharing degree of the entire graph from the resource dependency graph, and calculate the ratio of each sharing score to the maximum sharing degree of the entire graph to obtain the normalized value of sharing degree. The location index of each resource module is obtained from the topological sorting sequence, and the inverse value of the location is calculated based on the location index; wherein the location index is constructed using a counting method starting from zero; Based on the sharing degree weight coefficient and the topology location weight coefficient, the normalized value of the sharing degree and the inverse value of the location are weighted and summed to obtain the priority score of each unloaded resource module; wherein, the sum of the sharing degree weight coefficient and the topology location weight coefficient is 1; Multiply the product of the current network bandwidth and the estimated user dwell time by a preset bandwidth occupancy coefficient to obtain the bandwidth adaptation capacity, obtain the preset preload absolute capacity limit, and take the smaller value between the bandwidth adaptation capacity and the preload absolute capacity limit as the preload capacity limit. The unloaded resource modules in the second category of candidate resources are sorted from high to low according to the priority score to obtain the sorted unloaded resource modules; Initialize the total selected volume to zero, iterate through the sorted unloaded resource modules in sequence, and add the volume of the currently iterated resource module to the total selected volume to obtain the accumulated volume; If the accumulated volume does not exceed the preload capacity limit, the corresponding resource module is added to the second preload candidate set, and the selected total volume is updated to the accumulated volume; if the accumulated volume exceeds the preload capacity limit, the traversal operation is terminated, and the final second preload candidate set is obtained.

5. The method according to claim 1, characterized in that, The method further includes: The state at each preloading decision moment is set as a feature vector, which includes the current user behavior intent vector, the cache existence flag vector of each resource node in the resource dependency graph, the current network bandwidth, the current round-trip latency, and the current page path; The action is set as a binary vector, which is used to represent the selection result of selecting a subset from each of the resource modules to perform the resource preloading operation; The reward function is set as a preload hit reward minus the bandwidth cost penalty plus a latency improvement reward. The preload hit reward is calculated based on the actual number of preloaded resources used and the number of unused preloaded resources. The bandwidth cost penalty is calculated based on the total number of preloaded bytes. The latency improvement reward is calculated based on the baseline time without preload and the actual first-screen rendering time. Construct a policy network that shares underlying parameters with the graph attention network. The policy network takes the resource dependency graph and the user behavior intent vector as input and outputs the policy score and state value estimate of each resource module. The system acquires a four-tuple log of the actual operation process, including the state, actions, rewards, and the next state. The rewards are calculated using the reward function based on the actual number of preloaded resources used, the number of unused preloaded resources, the total number of preloaded bytes, the baseline time without preloading, and the actual first-screen rendering time. The next state is constructed by collecting the new user behavior intent vector, the cache presence flag vector of each resource node, the new network bandwidth, the new round-trip latency, and the new page path after the resource preloading operation is executed, according to the construction rules of the feature vector. Based on the quadruple log, the parameters of the policy network are updated using the near-end policy optimization algorithm to obtain the updated policy network parameters; The updated strategy network parameters are used to replace the output layer parameters of the graph attention network to obtain the updated graph attention network. The updated graph attention network is used as the computing network for the next round to calculate the user behavior intent vector for the next round and output the strategy score of each resource module. The strategy score is used to replace the access probability, and S3-S5 are repeated.

6. The method according to claim 1, characterized in that, The confidence level is calculated through the following steps: The predicted entropy value of each resource module is calculated based on the access probability. The difference between 1 and the predicted entropy value is defined as the confidence level.

7. The method according to claim 1, characterized in that, The upper limit of the preloaded capacity is calculated using the following formula: in, This indicates the upper limit of the preload capacity; This indicates the current network bandwidth; This indicates the estimated user dwell time; This represents the preset bandwidth utilization factor, with a value range of [value range missing]. ; Indicates the current network round-trip latency; Indicates the round-trip delay threshold; Indicates recent Variance of sub-bandwidth sampling ; Represents the minimum value, taking values ​​of This is used to avoid calculation errors where the denominator is zero; Indicates the maximum absolute capacity for preloading; This represents the failure compensation coefficient, with a value range of [value range missing]. ; This indicates the historical preloading failure rate.

8. A website static resource dynamic loading system, characterized in that, The system includes: The graph construction module is used to perform static analysis on multiple static resource modules of the target website, extract the static attributes of each resource module, and construct a resource dependency graph; perform topological sorting on the resource dependency graph to obtain a topological sorting sequence, and calculate the sharing degree score of each resource module based on the resource dependency graph; the static attributes include key tags on the first screen; The perception and prediction module is used to collect heterogeneous behavior sequences of users in real time, perform temporal modeling on the heterogeneous behavior sequences through a behavior feature encoder, and generate user behavior intent vectors; input the resource dependency graph and the user behavior intent vectors into a graph attention network, and output the access probability of each resource module; wherein, the heterogeneous behavior sequences include discrete behavior events, continuous behavior metrics and context state features. A high-confidence filtering module is used to calculate the confidence level of each resource module based on the access probability, and to select resource modules with a confidence level not lower than a preset confidence threshold as first-class candidate resources. Resource filtering is performed according to the access probability of the first-class candidate resources to obtain a first preloaded candidate set. The capacity-limited loading module is used to identify resource modules with confidence scores lower than the preset confidence threshold as second-class candidate resources, trigger a topology-preserving loading strategy, calculate the upper limit of preloading capacity based on the current network bandwidth and estimated user dwell time, extract unloaded resource modules from the second-class candidate resources from the topology sorting sequence, calculate the priority score of each unloaded resource module, and select unloaded resource modules in descending order of priority scores to add them to the second preloading candidate set until the total volume of the second preloading candidate set reaches the upper limit of preloading capacity, thus obtaining the final second preloading candidate set. The preloading execution module is used to merge the first preloading candidate set with the final second preloading candidate set to obtain the final preloading resource set; and to configure preloading instructions based on the first screen key tags of each resource module in the final preloading resource set. The preloading instructions are used to instruct the creation of corresponding link tags in reverse order of the topological sorting sequence, and to insert the link tags into the HTML document header to perform resource preloading operations.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.