A method, system, terminal, and medium for managing cached multi-tab page components.

By setting cache hierarchy markers and generating unique component names for Vue framework multi-tab page applications, the problems of data confusion and resource waste in cache management are solved, achieving efficient cache control and improved page rendering performance.

CN121301676BActive Publication Date: 2026-11-10SHANDONG INSPUR ULTRA HD INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511177587.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-21
Publication Date
2026-11-10
Estimated Expiration
2045-08-21

AI Technical Summary

Technical Problem

In Vue framework multi-tab page applications, caching management strategies suffer from issues such as data obfuscation, wasted memory resources, and low page rendering performance. Especially in scenarios with dynamic routing and nested routing, existing solutions cannot finely control the caching level, leading to excessive resource consumption or insufficient caching.

Method used

By setting a cache level marker for each route node, generating a unique component name, recursively processing child route nodes, generating a precise cache list, and responding to global state changes by performing local re-rendering, dynamic adjustment of the cache range and data synchronization are achieved.

Benefits of technology

It improves memory utilization, reduces invalid caching, enhances page rendering performance and interaction smoothness, and ensures stable performance of multi-tab pages under high-frequency switching and state updates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121301676B_ABST
    Figure CN121301676B_ABST
Patent Text Reader

Abstract

This application relates to the field of front-end web development technology, specifically providing a method, system, terminal, and medium for managing component caching in multi-tab pages. The method includes: setting a cache level marker for each route node in the routing configuration; generating a unique component identifier by intercepting route events; recursively filtering target components based on cache level depth to construct a precise cache list; and updating the affected component fields in a targeted manner using a difference comparison mechanism when responding to global state changes. This invention achieves efficient management of multi-tab page caching, improving memory utilization and page rendering performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of front-end web development technology, specifically to a method, system, terminal, and medium for managing cached multi-tab page components. Background Technology

[0002] In Vue framework multi-tab page applications, there are many problems with the related component caching management strategies: In dynamic routing scenarios, the same component still shares the same component name because it corresponds to routes with different parameters (such as user detail pages corresponding to different user IDs), resulting in cached content being overwritten, causing data confusion or display errors; In nested route structures, there is a lack of fine-grained control over the caching hierarchy, either caching all levels of child routes indiscriminately, causing excessive consumption of memory resources, or not caching deep-level components at all, causing users to need to reload the page when switching tabs, prolonging the waiting time; The generation logic of the cached component list mostly relies on simple matching rules and cannot be dynamically adjusted according to the route hierarchy, often including temporary pages that do not need to be cached in the cache list, or omitting key components that need to retain state, which wastes system resources and affects the effectiveness of caching; When the global state (such as user information, permission configuration, etc.) changes, the data in the cached components that depend on these states cannot be updated automatically. Existing solutions mostly use the method of re-rendering the cached components, which not only increases unnecessary computing overhead, but also causes page flickering and reduces the smoothness of interaction. Summary of the Invention

[0003] To address the aforementioned issues, this invention provides a method, system, terminal, and medium for managing multi-tab page component caches, enabling efficient management of multi-tab page caches and improving memory utilization and page rendering performance.

[0004] In a first aspect, the technical solution of the present invention provides a method for managing the cache of multi-tab page components, including the following steps: In the routing configuration, a cache level marker is set for each routing node. The cache level marker is used to indicate the cache level depth of the current routing node and its child nodes. When a user accesses a multi-tab page, intercept the route entry event, generate a unique identifier based on the current route's path and parameters, and use this identifier as the component name of the corresponding component; Starting from the currently active route node, obtain the cache level depth value of the route node and determine whether the value is valid. If invalid, terminate the cache processing flow of the current branch. If valid, add the component name corresponding to the current route node to the cache component list and decrement the level depth value of the current route node by one. Obtain all child route nodes of the current route node, traverse each child route node, take the current child route node as the new current route node, and re-execute this step using the updated cache level depth value. After all levels of recursive processing are completed, the components in the final generated cached component list are cached during the view rendering phase. The caching strategy variable responds to the global state, updates the affected data fields of the corresponding components in the cache component in real time, and performs a partial re-render.

[0005] In an optional implementation, a unique identifier is generated based on the path and parameters of the current route, specifically including the following steps: Extract the complete path and parameter list of the current route; Perform hash calculations on the parameter list to generate unique codes; The complete path is concatenated with the unique code to form a unique identifier.

[0006] In one optional implementation, determining whether the value is valid means determining whether the value is a positive integer. If it is, the value is valid; otherwise, the value is invalid.

[0007] In one optional implementation, in response to the global state's caching strategy variable, the affected data fields of the corresponding components in the caching component are updated in real time, and a partial re-render is performed, specifically including: When the application starts, register a global state change listener, which is used to capture data change requests; When the listener detects a state change event, if the change involves cached component data, it extracts the affected data identifier and the changed content. The data identifier and the changed content are encapsulated into an asynchronous task and submitted to the task queue of a background thread, which runs independently of the main rendering thread. The background thread executes asynchronous tasks, including retrieving all associated cache component instances based on the data identifier, comparing the current cache state with the changed content, and generating a list of components that need to be updated. Iterate through all components in the list of components that need to be updated, get the latest data, update the affected fields of the current component based on the latest data, and trigger a partial re-render of the current component.

[0008] In an optional implementation, after caching the components in the list during the view rendering phase, the method further includes: Record the access frequency and timestamp of each cached component. When memory usage exceeds the threshold, prioritize cleaning up components with the lowest access frequency that have not been used within the most recent period of time.

[0009] In an optional implementation, the method further includes a step of managing state recovery through lifecycle hook functions when a component is activated and deactivated, specifically including: When a component is instantiated, a dedicated state storage object is created. The data structure contained in this object includes a scrollbar position record field, a form input state record field, and a temporary data storage area inside the component. When a component is detected to be inactive, the scroll bar position coordinates of the current scroll container element are obtained through the browser interface based on the first lifecycle hook function. All form elements in the component are traversed, and their current input values ​​and selection states are recorded. The obtained scroll bar position coordinates, current form input values ​​and selection states, as well as the target temporary data in the component are serialized and stored in the state storage object. When a component is detected to be reactivated, the corresponding state data is read from the state storage object based on the second lifecycle hook function, the scroll container element is positioned to the recorded coordinates, the input values ​​and selection states of the form elements are restored one by one, and the temporary data is re-injected into the component instance.

[0010] In an optional implementation, the method further includes the following steps: Real-time collection of performance metrics, including page switching time, memory usage, and CPU utilization; If any dimension of the performance metric exceeds the corresponding threshold, the cache level mark of the current routing node is reduced, and cached components are recursively cleaned up along the parent-child relationship. If all dimensions of the performance vector are below the corresponding threshold and the user return frequency is higher than the second threshold, then increase the cache level mark of the current routing node and recursively cache the new level components along the parent-child relationship.

[0011] Secondly, the technical solution of the present invention provides a multi-tab page component caching management system, including: The cache level marking module is used to set a cache level marking for each route node in the route configuration. The cache level marking is used to indicate the cache level depth of the current route node and its child nodes. The component naming module is used to intercept the route entry event when a user accesses a multi-tab page, generate a unique identifier based on the current route path and parameters, and use this identifier as the component name of the corresponding component. The cache component filtering module is used to start from the currently active route node, obtain the cache level depth value of the route node, and determine whether the value is valid. If invalid, the cache processing flow of the current branch is terminated. If valid, the component name corresponding to the current route node is added to the cache component list, and the level depth value of the current route node is decremented by one. All child route nodes of the current route node are obtained, each child route node is traversed, the current child route node is used as the new current route node, and the module is re-executed using the updated cache level depth value. The component caching implementation module is used to implement caching operations on the components in the final generated cached component list during the view rendering phase after all levels of recursive processing have been completed. The state synchronization module is used to respond to the global state caching strategy variables, update the affected data fields of the corresponding components in the cache component in real time, and perform local re-rendering.

[0012] Thirdly, the technical solution of the present invention provides a terminal, including: Memory, used to store the cache management program for multi-tab page components; A processor, configured to implement the steps of the multi-tab page component cache management method as described above when executing the multi-tab page component cache management program.

[0013] Fourthly, the present invention provides a computer-readable storage medium storing a multi-tab page component cache management program, wherein the multi-tab page component cache management program, when executed by a processor, implements the steps of the multi-tab page component cache management method as described in any of the above claims.

[0014] As can be seen from the above technical solutions, this application has the following advantages: 1. This application sets a cache level flag for each route node in the route configuration, and builds a cache control based on the level depth. This allows the system to accurately set the cache range of the current route node and its child nodes according to business needs. When the level depth value decreases to invalid, the caching process of that branch is automatically terminated. This avoids the problem of excessive memory consumption caused by indiscriminate caching or repeated page loading caused by insufficient caching in nested route scenarios, and realizes the reasonable allocation of cache resources. 2. This application intercepts route entry events and generates a unique identifier as the component name based on the current route's path and parameters, enabling dynamic routes with different parameters (such as different data IDs corresponding to the same page template) to obtain differentiated component identifiers. This solves the conflict problems such as cache content overwriting and data confusion caused by the same component name in traditional methods, and ensures the accuracy of caching in dynamic routing scenarios. 3. This application recursively processes all child routing nodes starting from the activated routing node, and combines the updated cache level depth value to filter components that need to be cached and generate an accurate cache list. Only necessary components that meet the level requirements are included in the cache scope, and redundant components that do not need to be cached are eliminated. This significantly reduces the memory and computing resources occupied by invalid cache and improves the resource utilization efficiency of cache management. 4. This application uses a caching strategy variable that responds to the global state. When the global state changes, it only updates the affected data fields in the cache component in real time and triggers a partial re-render. This avoids the increased computational overhead and page flickering caused by traditional full re-rendering, effectively improving the timeliness of data synchronization in the cache component and the smoothness of page interaction, and ensuring the stable performance of multi-tab page applications in high-frequency switching and state update scenarios. Attached Figure Description

[0015] To more clearly illustrate the technical solution of this application, the accompanying drawings used in the description 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.

[0016] Figure 1 This is a schematic diagram of a multi-tab page component cache management method provided in an embodiment of the present invention.

[0017] Figure 2 This is a schematic block diagram of a multi-tab page component cache management system provided in an embodiment of the present invention.

[0018] Figure 3 This is a schematic diagram of the structure of a terminal provided in an embodiment of the present invention. Detailed Implementation

[0019] To make the purpose, features, and advantages of this application more apparent and understandable, specific embodiments and accompanying drawings will be used to clearly and completely describe the technical solution protected by this application. Obviously, the embodiments described below are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0020] Unless otherwise defined, all technical and scientific terms used in this application have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used in this application and in the specification of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.

[0021] The key terms used in this invention will be explained below.

[0022] Multi-tab page: Multiple page views displayed in parallel within the same browser window, each maintaining an independent state.

[0023] Routing: Configuration rules that map URL paths to corresponding component trees, including attributes such as path and component.

[0024] Components: Reusable Vue instances, each route corresponds to a root component and a component tree consisting of its nested child components.

[0025] Figure 1 This is a schematic flowchart illustrating a multi-tab page component cache management method provided in an embodiment of the present invention. Figure 1 The executing entity can be a multi-tab page component caching management system. The multi-tab page component caching management method provided in this embodiment of the invention is executed by a computer device, and correspondingly, the multi-tab page component caching management system runs on the computer device. Depending on different needs, the order of the steps in this flowchart can be changed, and some steps can be omitted.

[0026] like Figure 1 As shown, the method includes the following steps.

[0027] S1. In the routing configuration, a cache level marker is set for each routing node. The cache level marker is used to indicate the cache level depth of the current routing node and its child nodes.

[0028] In the route configuration file, a cache level flag, `cacheLevel`, is added to the `meta` field of each route node. This flag is a non-negative integer used to define the cache level depth of the current route node and its child nodes. The value of the `cacheLevel` flag can be defined by developers according to business needs, specifically based on page importance, state complexity, user access patterns, etc. When a route is not explicitly set, the `cacheLevel` of the parent route is decremented by 1. If the result is less than 0, caching is terminated. The root route is not cached by default if no cache level is set.

[0029] For example, in an enterprise-level project management system, the homepage is a frequently accessed and relatively stable page. Developers can set the cache level flag of its route nodes to a high value, such as 3. This means that not only are the homepage's own components cached, but the components corresponding to its three levels of child route nodes will also be cached according to this rule, reducing the overhead of repeated loading.

[0030] For nested routing systems with a clear hierarchical structure, automatic deduction rules based on routing hierarchy relationships can be formulated. When the cache level flag is set to 2 on the root route, the system can automatically assign a cache level flag of 1 to the first-level sub-routes, a cache level flag of 0 to the second-level sub-routes, and an invalid value (such as -1) to the cache level flag of the third-level sub-routes, according to the established rules. In this way, the system can automatically determine the cache depth of each level component based on the routing hierarchy.

[0031] S2: When a user accesses a multi-tab page, intercept the route entry event, generate a unique identifier based on the current route path and parameters, and use this identifier as the component name of the corresponding component.

[0032] In some optional implementations, generating a unique identifier based on the path and parameters of the current route specifically includes: extracting the complete path and parameter list of the current route; performing a hash calculation on the parameter list to generate a unique code; and concatenating the complete path with the unique code to form a unique identifier.

[0033] Specifically, when a user triggers a route jump in a multi-tab application, such as by clicking a navigation menu, switching tabs, or calling a route jump method programmatically, the system captures the route entry event through a route interception mechanism, prevents the default component name assignment logic, and initiates the custom identifier generation process.

[0034] Retrieves the complete path string and parameter list from the current route object. The complete path is the path template in the route configuration, and the parameter list contains all the dynamic parameters carried by the route.

[0035] The system directly assigns the generated unique identifier to the name attribute of the component instance corresponding to the current route, replacing the traditional fixed component name. When the user subsequently accesses routes with the same path but different parameters, the system will repeat the custom identifier generation process to generate different unique identifiers, ensuring that dynamic route components with different parameters obtain differentiated names and achieving cache isolation.

[0036] S3: Starting from the currently active route node, obtain the cache level depth value of the route node and determine whether the value is valid. If invalid, terminate the cache processing flow of the current branch. If valid, add the component name corresponding to the current route node to the cache component list and decrement the level depth value of the current route node by one. Obtain all child route nodes of the current route node, traverse each child route node, take the current child route node as the new current route node, and re-execute this step using the updated cache level depth value.

[0037] Determining whether a value is valid means checking if it is a positive integer. If it is, the value is valid; otherwise, it is invalid.

[0038] For example, taking the currently active route node "dashboard" as the starting node, whose cache level marker is preset to 2, we first obtain its cache level depth value of 2. Since 2 is a positive integer, it is considered valid, and the unique identifier of the component corresponding to this node is added to the cached component list; then, the level depth value is decremented by one, resulting in an updated value of 1.

[0039] Retrieve all child route nodes / dashboard / analysis and / dashboard / statistics under / dashboard, and process them one by one. For the child route node / dashboard / analysis, treat it as the new current route node, and use the updated hierarchy depth value of 1 (a positive integer, valid for verification). Add its unique component identifier to the cached component list, and then decrement the hierarchy depth value to 0.

[0040] Continue retrieving child route nodes of / dashboard / analysis, such as / dashboard / analysis / realtime, and use this node as the current route node, with a hierarchy depth of 0. Since 0 is not a positive integer, it is considered invalid, the caching process for this branch is terminated, and its components are not added to the cache list.

[0041] For the other child route node / dashboard / statistics, similarly, use a hierarchy depth value of 1 (valid), add its component identifier to the cache list, and then decrease the hierarchy depth value to 0; its child route nodes (such as / dashboard / statistics / history) will have their branch processing terminated because they use a hierarchy depth value of 0 (invalid).

[0042] The recursive processing of the current branch terminates when the cache level depth of a routing node is a non-positive integer (such as 0 or -1) after being decremented, or when the node has no child routes.

[0043] Through the above recursive process, the final generated list of cached components only contains the component identifiers corresponding to the three nodes: / dashboard, / dashboard / analysis, and / dashboard / statistics, thus achieving precise cache range control based on hierarchical depth.

[0044] S4. After all levels of recursive processing are completed, cache operations are performed on the components in the final generated cache component list during the view rendering phase.

[0045] During the view rendering phase, the page caching control component reads the final generated list of cached components and matches the unique identifiers of the components in the list with the name attribute of all component instances currently to be rendered. Only components whose names match are cached: when a component is first rendered, its DOM structure, data state, and lifecycle state are stored in a memory cache; when a component is temporarily hidden due to a route change, it is not destroyed, but its cached state in memory is retained.

[0046] For components that do not appear in the cached component list, the page cache control component will not cache them, and will destroy the instance according to the normal process when the component is hidden, releasing the memory resources it occupies.

[0047] When a user revisits a cached component, the system directly reads the component's historical state from the memory cache and resumes rendering, without having to re-execute the initialization, data requests, and DOM construction process, significantly shortening page load time.

[0048] In some optional implementations, an improved Least Recently Used (LRU) algorithm is used to monitor system memory usage. When memory usage reaches a preset threshold, cached components with low usage frequency are automatically cleaned up. Specifically, the access frequency and timestamp of each cached component are recorded. When memory usage exceeds the threshold, components with the lowest access frequency and that have not been used within the recent certain period are prioritized for cleanup.

[0049] S5 responds to the global state caching strategy variable, updates the affected data fields of the corresponding components in the cache component in real time, and performs local re-rendering, specifically including the following steps.

[0050] S5.1 Registers a global state change listener when the application starts. This listener is used to capture data change requests.

[0051] S5.2 When the listener detects a state change event, if the change involves cached component data, it extracts the affected data identifier and the changed content.

[0052] S5.3, the data identifier and the changed content are encapsulated into an asynchronous task and submitted to the task queue of the background thread, which runs independently of the main rendering thread.

[0053] S5.4, the background thread executes asynchronous tasks, including retrieving all associated cache component instances based on the data identifier, comparing the current cache state with the changed content, and generating a list of components that need to be updated.

[0054] S5.5 Iterate through all components in the list of components that need to be updated, get the latest data, update the affected fields of the current component based on the latest data, and trigger a partial re-render of the current component.

[0055] For example, when a user modifies the product inventory, the listener captures the mutation call to products / updateStock, parses the changed content: { sku: 'A203', stock: 15}, and confirms through the route mapping table that the affected component is ProductDetail.vue.

[0056] Searching all cached instances based on sku=A203 revealed that three open tabs contained this product: Tag 1: / product / A203 (Currently Active) Tag 2: / product / A203?from=cart Tag 3: / compare / A203_vs_B456 Taking the update operation of tag 1 as an example: the patch method only updates the $store.state.product.stock field, and calling this.$forceUpdate() triggers a partial repaint. After the update, the DOM changes only involve the inventory number (from 20 to 15) and the inventory warning icon (from gray to red) on the product details page.

[0057] In some alternative implementations, the method further includes step S6, which manages the restoration of state through lifecycle hook functions when a component is activated and deactivated, specifically including the following steps.

[0058] S6.1 When a component is instantiated, a dedicated state storage object is created. The data structure contained in this object includes a scroll bar position record field, a form input state record field, and a temporary data storage area inside the component.

[0059] S6.2 When a component is detected to be inactive, the scroll bar position coordinates of the current scroll container element are obtained through the browser interface based on the first lifecycle hook function. All form elements in the component are traversed, and their current input values ​​and selection states are recorded. The obtained scroll bar position coordinates, current form input values ​​and selection states, and target temporary data in the component are serialized and stored in the state storage object.

[0060] When a user switches tabs, that is, when switching from one tab to another, the component's deactivated lifecycle hook is triggered, and step S6.2 is achieved through this hook.

[0061] S6.3 When a component is detected to be reactivated, the corresponding state data is read from the state storage object based on the second lifecycle hook function, the scroll container element is positioned to the recorded coordinate position, the input value and selection state of each form element are restored one by one, and the temporary data is re-injected into the component instance.

[0062] When the user switches back to the previous tab, the component's activated lifecycle hook is triggered, and step S6.3 is achieved through this hook.

[0063] Through the above process, when users return to the original page after switching tabs, they can directly restore their browsing position, form filling status, and temporary edited content when they left, without having to do it again, thus improving the interactive continuity of multi-tab pages.

[0064] In some optional implementations, the method further includes step S7: real-time collection of performance metrics, including page switching time, memory usage, and CPU utilization; if any dimension of the performance metric exceeds the corresponding threshold, the cache level mark of the current routing node is reduced, and cached components are recursively cleaned up along the parent-child relationship; if all dimensions of the performance vector are below the corresponding threshold and the user return frequency is higher than the second threshold, the cache level mark of the current routing node is increased, and newly added level components are recursively cached along the parent-child relationship. The system automatically reduces the cache scope to ensure operational stability when resources are scarce, and expands the cache level to improve access speed when resources are abundant and user demand is high, achieving a dynamic balance between cache efficiency and system performance.

[0065] The foregoing has described in detail an embodiment of a multi-tab page component cache management method. Based on the multi-tab page component cache management method described in the above embodiment, this invention also provides a multi-tab page component cache management system corresponding to the method.

[0066] Figure 2 This is a schematic block diagram of a multi-tab page component caching management system provided in an embodiment of the present invention. In this embodiment, the multi-tab page component caching management system 200 can be divided into multiple functional modules according to the functions it performs. A module, as referred to in this invention, is a series of computer program segments that can be executed by at least one processor and perform a fixed function, and is stored in memory.

[0067] The cache level marking module 210 is used to set a cache level marking for each routing node in the routing configuration. The cache level marking is used to indicate the cache level depth of the current routing node and its child nodes.

[0068] The component naming module 220 is used to intercept the route entry event when a user accesses a multi-tab page, generate a unique identifier based on the path and parameters of the current route, and use the identifier as the component name of the corresponding component.

[0069] The cache component filtering module 230 is used to start from the currently active route node, obtain the cache level depth value of the route node, and determine whether the value is valid. If invalid, the cache processing flow of the current branch is terminated. If valid, the component name corresponding to the current route node is added to the cache component list, and the level depth value of the current route node is decremented by one. All child route nodes of the current route node are obtained, each child route node is traversed, the current child route node is used as the new current route node, and the module is re-executed using the updated cache level depth value.

[0070] The component caching implementation module 240 is used to perform caching operations on the components in the view rendering stage based on the final generated cached component list after all levels of recursive processing have been completed.

[0071] The state synchronization module 250 is used to respond to the global state caching strategy variable, update the affected data fields of the corresponding components in the cache component in real time, and perform local re-rendering.

[0072] In some optional implementations, system 200 further includes a state recovery and cleanup module 260, used to manage state recovery through lifecycle hook functions when a component is activated or deactivated: when a component is instantiated, a dedicated state storage object is created, the data structure of which includes a scrollbar position recording field, a form input state recording field, and a temporary data storage area inside the component; when a component is detected to be deactivated, the scrollbar position coordinates of the current scroll container element are obtained through the browser interface based on the first lifecycle hook function, all form elements within the component are traversed, and their current input values ​​and selection states are recorded; the obtained scrollbar position coordinates, current form input values ​​and selection states, and target temporary data within the component are serialized and stored in the state storage object; when a component is detected to be reactivated, the corresponding state data is read from the state storage object based on the second lifecycle hook function, the scroll container element is positioned to the recorded coordinate position, the input values ​​and selection states of the form elements are restored one by one, and the temporary data is re-injected into the component instance.

[0073] In some optional implementations, system 200 also includes a cache level dynamic adjustment module 270, which is used to collect performance indicators in real time, including page switching time, memory usage, and CPU usage. If any dimension of the performance indicator exceeds the corresponding threshold, the cache level mark of the current routing node is reduced, and cached components are recursively cleaned up along the parent-child relationship. If all dimensions of the performance vector are lower than the corresponding threshold and the user return frequency is higher than the second threshold, the cache level mark of the current routing node is increased, and newly added level components are recursively cached along the parent-child relationship.

[0074] The multi-tab page component cache management system of this embodiment is used to implement the aforementioned multi-tab page component cache management method. Therefore, the specific implementation of this system can be found in the embodiment section of the multi-tab page component cache management method above. Thus, its specific implementation can be referred to the description of the corresponding embodiments, and will not be elaborated here.

[0075] Furthermore, since the multi-tab page component cache management system in this embodiment is used to implement the aforementioned multi-tab page component cache management method, its function corresponds to the function of the above method, and will not be repeated here.

[0076] Figure 3 A schematic diagram of a terminal 300 provided in an embodiment of the present invention includes: a processor 310, a memory 320, and a communication unit 330. The processor 310 is used to implement the following steps when implementing the multi-tab page component cache management program stored in the memory 320: In the routing configuration, a cache level marker is set for each routing node. The cache level marker is used to indicate the cache level depth of the current routing node and its child nodes. When a user accesses a multi-tab page, intercept the route entry event, generate a unique identifier based on the current route's path and parameters, and use this identifier as the component name of the corresponding component; Starting from the currently active route node, obtain the cache level depth value of the route node and determine whether the value is valid. If invalid, terminate the cache processing flow of the current branch. If valid, add the component name corresponding to the current route node to the cache component list and decrement the level depth value of the current route node by one. Obtain all child route nodes of the current route node, traverse each child route node, take the current child route node as the new current route node, and re-execute this step using the updated cache level depth value. After all levels of recursive processing are completed, the components in the final generated cached component list are cached during the view rendering phase. The caching strategy variable responds to the global state, updates the affected data fields of the corresponding components in the cache component in real time, and performs a partial re-render.

[0077] The terminal 300 includes a processor 310, a memory 320, and a communication unit 330. These components communicate via one or more buses. Those skilled in the art will understand that the server structure shown in the figure does not constitute a limitation of the present invention. It can be a bus topology or a star topology, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0078] The memory 320 can be used to store the execution instructions of the processor 310. The memory 320 can be implemented by any type of volatile or non-volatile memory terminal or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. When the execution instructions in the memory 320 are executed by the processor 310, the terminal 300 is able to perform some or all of the steps in the above method embodiments.

[0079] The processor 310 serves as the control center of the storage terminal, connecting various parts of the electronic terminal via various interfaces and lines. It executes software programs and / or modules stored in the memory 320, and calls data stored in the memory to perform various functions of the electronic terminal and / or process data. The processor can be composed of integrated circuits (ICs), such as a single packaged IC or multiple packaged ICs with the same or different functions connected together. For example, the processor 310 may consist only of a central processing unit (CPU). In this embodiment of the invention, the CPU may have a single processing core or include multiple processing cores.

[0080] The communication unit 330 is used to establish a communication channel, enabling the storage terminal to communicate with other terminals. It can receive user data sent by other terminals or send user data to other terminals.

[0081] The present invention also provides a computer storage medium, which may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0082] The present invention also provides a computer storage medium, which may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM), etc.

[0083] The computer storage medium stores a multi-tab page component cache manager, which performs the following steps when executed by the processor: In the routing configuration, a cache level marker is set for each routing node. The cache level marker is used to indicate the cache level depth of the current routing node and its child nodes. When a user accesses a multi-tab page, intercept the route entry event, generate a unique identifier based on the current route's path and parameters, and use this identifier as the component name of the corresponding component; Starting from the currently active route node, obtain the cache level depth value of the route node and determine whether the value is valid. If invalid, terminate the cache processing flow of the current branch. If valid, add the component name corresponding to the current route node to the cache component list and decrement the level depth value of the current route node by one. Obtain all child route nodes of the current route node, traverse each child route node, take the current child route node as the new current route node, and re-execute this step using the updated cache level depth value. After all levels of recursive processing are completed, the components in the final generated cached component list are cached during the view rendering phase. The caching strategy variable responds to the global state, updates the affected data fields of the corresponding components in the cache component in real time, and performs a partial re-render.

[0084] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of the present invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium such as a USB flash drive, mobile hard drive, read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, or other media capable of storing program code. It includes several instructions to cause a computer terminal (which may be a personal computer, server, or a second terminal, network terminal, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention.

[0085] In the embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0086] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0087] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0088] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for managing the cache of multi-tab page components, characterized in that, Includes the following steps: In the routing configuration, a cache level marker is set for each routing node. The cache level marker is used to indicate the cache level depth of the current routing node and its child nodes. When a user accesses a multi-tab page, intercept the route entry event, generate a unique identifier based on the current route's path and parameters, and use this identifier as the component name of the corresponding component; Starting from the currently active route node, obtain the cache level depth value of the route node and determine whether the value is valid. If invalid, terminate the cache processing flow of the current branch. If valid, add the component name corresponding to the current route node to the cache component list and decrement the level depth value of the current route node by one. Obtain all child route nodes of the current route node, traverse each child route node, take the current child route node as the new current route node, and re-execute this step using the updated cache level depth value. After all levels of recursive processing are completed, the components in the final generated cached component list are cached during the view rendering phase. The caching strategy variable responds to the global state, updates the affected data fields of the corresponding components in the cache component in real time, and performs a partial re-render.

2. The multi-tab page component cache management method according to claim 1, characterized in that, Generate a unique identifier based on the current route path and parameters, specifically including the following steps: Extract the complete path and parameter list of the current route; Perform hash calculations on the parameter list to generate unique codes; The complete path is concatenated with the unique code to form a unique identifier.

3. The multi-tab page component cache management method according to claim 1, characterized in that, Determining whether a value is valid means checking if it is a positive integer. If it is, the value is valid; otherwise, the value is invalid.

4. The multi-tab page component cache management method according to claim 1, characterized in that, In response to global state caching strategy variables, the affected data fields of the corresponding components in the cached components are updated in real time, and partial re-rendering is performed, specifically including: When the application starts, register a global state change listener, which is used to capture data change requests; When the listener detects a state change event, if the change involves cached component data, it extracts the affected data identifier and the changed content. The data identifier and the changed content are encapsulated into an asynchronous task and submitted to the task queue of a background thread, which runs independently of the main rendering thread. The background thread executes asynchronous tasks, including retrieving all associated cache component instances based on the data identifier, comparing the current cache state with the changed content, and generating a list of components that need to be updated. Iterate through all components in the list of components that need to be updated, get the latest data, update the affected fields of the current component based on the latest data, and trigger a partial re-render of the current component.

5. The multi-tab page component cache management method according to claim 1, characterized in that, After caching the components in the list during the view rendering phase, the following steps are also included: Record the access frequency and timestamp of each cached component. When memory usage exceeds the threshold, prioritize cleaning up components with the lowest access frequency that have not been used within the most recent period of time.

6. The multi-tab page component cache management method according to claim 1, characterized in that, The method also includes steps for managing state recovery through lifecycle hook functions when a component is activated and deactivated, specifically including: When a component is instantiated, a dedicated state storage object is created. The data structure contained in this object includes a scrollbar position record field, a form input state record field, and a temporary data storage area inside the component. When a component is detected to be inactive, the scroll bar position coordinates of the current scroll container element are obtained through the browser interface based on the first lifecycle hook function. All form elements in the component are traversed, and their current input values ​​and selection states are recorded. The obtained scroll bar position coordinates, current form input values ​​and selection states, as well as the target temporary data in the component are serialized and stored in the state storage object. When a component is detected to be reactivated, the corresponding state data is read from the state storage object based on the second lifecycle hook function, the scroll container element is positioned to the recorded coordinates, the input values ​​and selection states of the form elements are restored one by one, and the temporary data is re-injected into the component instance.

7. The multi-tab page component cache management method according to claim 1, characterized in that, The method also includes the following steps: Real-time collection of performance metrics, including page switching time, memory usage, and CPU utilization; If any dimension of the performance metric exceeds the corresponding threshold, the cache level mark of the current routing node is reduced, and cached components are recursively cleaned up along the parent-child relationship. If all dimensions of the performance vector are below the corresponding threshold and the user return frequency is higher than the second threshold, then increase the cache level mark of the current routing node and recursively cache the new level components along the parent-child relationship.

8. A multi-tab page component caching management system, characterized in that, include: The cache level marking module is used to set a cache level marking for each route node in the route configuration. The cache level marking is used to indicate the cache level depth of the current route node and its child nodes. The component naming module is used to intercept the route entry event when a user accesses a multi-tab page, generate a unique identifier based on the current route path and parameters, and use this identifier as the component name of the corresponding component. The cache component filtering module starts from the currently active route node, retrieves the cache level depth value of that route node, and determines whether the value is valid. If invalid, the cache processing flow of the current branch is terminated; if valid, the component name corresponding to the current route node is added to the cache component list, and the level depth value of the current route node is decremented by one. It then retrieves all child route nodes of the current route node, iterates through each child route node, uses the current child route node as the new current route node, and re-executes the module using the updated cache level depth value. The component caching implementation module is used to perform caching operations on the components in the final generated cached component list during the view rendering phase after all levels of recursive processing have been completed. The state synchronization module is used to respond to the global state caching strategy variables, update the affected data fields of the corresponding components in the cache component in real time, and perform local re-rendering.

9. A terminal, characterized in that, include: Memory, used to store the cache management program for multi-tab page components; A processor, configured to implement the steps of the multi-tab page component cache management method as described in any one of claims 1 to 7 when executing the multi-tab page component cache management program.

10. A computer-readable storage medium, characterized in that, The readable storage medium stores a multi-tab page component cache management program, which, when executed by a processor, implements the steps of the multi-tab page component cache management method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Front-end page generation method and device and medium

    CN119088392A

  • Tree component optimization method based on React framework and fusing virtualization rendering and increment rendering

    CN119668568A