Webpage application code updating method and device and computer equipment
By implementing the web application code update method on the server, and sending incremental update code or full file based on the version number of the resource file, the problem of needing to re-download the entire file after partial update of the front-end code file is solved, and the web page loading speed and user experience are improved.
Patent Information
- Application Number
- CN202411765246.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-03
- Publication Date
- 2025-05-06
AI Technical Summary
The existing technology cannot effectively solve the problem of re-downloading of the entire file after partial update of the front-end code file, resulting in slowing down the loading speed of web pages and decreasing user experience.
Implement the web application code update method on the server. By receiving the client's network request, determine the current version number of the resource file, and decide whether to send an incremental update code file or a full file based on the minimum version number corresponding to the resource file.
By incrementally updating code files, reduce the amount of data that needs to be transferred, improve web page loading speed, reduce network bandwidth usage and server load, and optimize the performance of web page applications.
Smart Images

Figure CN119938114A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of front-end development, and in particular to a webpage application code updating method, device and computer equipment. Background Art
[0002] With the rapid development of Web technology, front-end engineers are able to create web pages with rich functions and excellent visual effects. However, these complex functions and exquisite visual effects are often accompanied by an increase in file size, which will have a negative impact on the loading speed of the web page, thereby affecting the user experience. The loading speed of a web page has a crucial impact on its user experience. Studies have shown that users have higher and higher requirements for the loading speed of web pages. If a web page takes too long to load, users are likely to give up waiting and leave the web page. Therefore, optimizing web page performance and increasing web page loading speed are crucial to improving user satisfaction and maintaining user stickiness.
[0003] To solve this problem, front-end engineers have adopted a variety of optimization strategies. Among them, file compression and browser caching are the two most commonly used strategies. File compression can reduce the size of web page files, thereby speeding up the loading of web pages. Common file compression methods include compressing images, compressing JavaScript and CSS files, and using advanced image formats such as WebP. These compression methods can effectively reduce file size and increase web page loading speed. Browser caching is a technology that uses browsers to store resources. Through browser caching, when a user visits the same web page again, the browser can directly load the resources that have been visited from the local cache without having to download them from the server again. This can greatly reduce web page loading time and improve user experience.
[0004] However, the current optimization strategy cannot solve the problem that the entire file needs to be downloaded again after a part of a front-end code file is updated. Summary of the invention
[0005] In view of this, the present invention provides a web application code update method, device and computer equipment to solve the problem that the entire file needs to be re-downloaded after a front-end code file is partially updated.
[0006] In a first aspect, the present invention provides a web application code update method, which is applied to a server and includes the following steps: receiving a network request sent by a client; determining whether the network request contains the current version number of a resource file; when the network request contains the current version number of the resource file, obtaining the minimum version number corresponding to the resource file; when the current version number is higher than the minimum version number, sending the incremental update code file corresponding to the resource file to the client; when the current version number is lower than the minimum version number, sending the full file corresponding to the resource file to the client.
[0007] The web application code update method of the server provided by the present invention, upon receiving a network request sent by a client, when the current version number of the resource file is higher than the minimum version number, the incremental update code file corresponding to the resource file is sent to the client, and the code incremental update can be performed based on the original file, reducing the amount of data that needs to be transmitted, speeding up the web page loading speed, and improving the user experience. At the same time, since only the incremental update code is transmitted, the network bandwidth occupation can also be reduced, the server load can be reduced, and the performance of the web application can be optimized. In addition, by setting the minimum version number, before sending the incremental update code file to the client, the current version number of the resource file is compared with the minimum version number, and when the current version number of the resource file is lower than the minimum version number corresponding to the resource file, the full file corresponding to the resource file is sent to the client, so that when a large number of updates occur to the content of the resource file, the full update can be directly adopted to avoid complex incremental calculations, thereby improving the update efficiency.
[0008] In an optional embodiment, before the incremental update code file from the current version to the latest version corresponding to the resource file is sent to the client, the following steps are also included: determine whether there is an update script from the current version to the latest version; when it exists, use the update script as the incremental update code file; when it does not exist, splice multiple update scripts between the current version and the latest version to obtain an incremental update code file and save it; wherein the update script generation method includes: when it is monitored that the resource file is updated, obtain the pre-update file and the post-update file of the resource file; convert the pre-update file and the post-update file into an abstract syntax tree structure; compare the pre-update file and the post-update file converted into the abstract syntax tree structure to obtain the update script of the resource file.
[0009] That is to say, when the network request received by the server contains the current version number of the resource file, the following two situations exist: (1) the server has an incremental update code file from the current version to the latest version; (2) the server does not have an incremental update code file from the current version to the latest version. In case (2), multiple update scripts between the current version and the latest version are spliced to obtain an incremental update code file and save it. Therefore, the next time a network request carrying the current version number is received, the spliced incremental update code file can be directly sent to the client, reducing the client's waiting time and optimizing the server's resource utilization. Furthermore, the update script generation method uses an abstract syntax tree structure for comparison, thereby being able to ignore irrelevant information and having higher accuracy, greater flexibility, and better maintainability.
[0010] In an optional implementation, the web application code update method on the server side further includes the following steps: when the network request does not contain the current version number of the resource file, sending the full file of the latest version corresponding to the resource file to the client.
[0011] This makes the webpage application code update method applicable to a variety of application scenarios.
[0012] In a second aspect, the present invention also provides a web application code update method, which is applied to a client and includes the following steps: intercepting a network request of a web application and determining a response method to the network request; when the response method to the network request is to obtain resources from the network, determining whether the current cache contains a resource file corresponding to the network request; when the current cache contains a resource file corresponding to the network request, adding the current version number of the resource file to the network request and sending it to the server; when the current cache does not contain a file corresponding to the network request, sending the network request to the server; receiving a response file returned by the server, and determining whether the resource file is a full file or an incremental update code file; when the resource file is an incremental update code file, obtaining the resource file in the current cache, using the incremental update code file to update the resource file to obtain an update file, using the update file to update the current cache, and returning the update file to the web application.
[0013] The web application code update method provided by the present invention intercepts the network request of the web application. When the response mode to the network request is to obtain resources from the network, the response file returned by the server is received, and it is determined whether the resource file is a full file or an incremental update code file; when the resource file is an incremental update code file, the resource file is obtained in the current cache, and the resource file is updated by using the incremental update code file to obtain an update file, and the current cache is updated by using the update file, and the update file is returned to the web application; thereby, the code is incrementally updated based on the original file, the amount of data to be transmitted is reduced, the web page loading speed is accelerated, and the user experience is improved. At the same time, since only the incremental update code is transmitted, the network bandwidth occupation can also be reduced, the server load is reduced, and the performance of the web application is optimized. In an optional implementation, determining the response mode to the network request includes: when the resource file corresponding to the network request belongs to a static resource, the response mode to the network request is to obtain the resource file in the current cache and return the resource file to the web application; when the resource file corresponding to the network request does not belong to a static resource, the response mode to the network request is to obtain the resource from the network.
[0014] This can improve the performance of web applications, reduce dependence on the network, speed up response, and improve the overall performance of web applications. At the same time, it can support web applications to implement custom caching functions and improve the stability of web applications.
[0015] In the third aspect, the present invention also provides a web application code update device, which is applied to a server, and includes a network request receiving module, a judgment module, a minimum version number acquisition module and a sending module; the network request receiving module is used to receive a network request sent by a client; the judgment module is used to judge whether the network request contains the current version number of the resource file; the minimum version number acquisition module is used to obtain the minimum version number corresponding to the resource file when the network request contains the current version number of the resource file; the sending module is used to send the incremental update code file corresponding to the resource file to the client when the current version number is higher than the minimum version number; when the current version number is lower than the minimum version number, the full file corresponding to the resource file is sent to the client.
[0016] In a fourth aspect, the present invention further provides a web application code update device, which is applied to a client, and includes a response mode determination module, a judgment module, a network request sending module, a response file receiving module, and a processing module; the response mode determination module is used to intercept the network request of the web application and determine the response mode to the network request; the judgment module is used to determine whether the current cache contains a resource file corresponding to the network request when the response mode to the network request is to obtain resources from the network;
[0017] The network request sending module is used to add the current version number of the resource file in the network request and then send it to the server when the current cache contains a resource file corresponding to the network request; when the current cache does not contain a file corresponding to the network request, the network request is sent to the server; the response file receiving module is used to receive the response file returned by the server and determine whether the resource file is a full file or an incremental update code file; the processing module is used to obtain the resource file in the current cache when the resource file is an incremental update code file, update the resource file using the incremental update code file to obtain an update file, update the current cache using the update file, and return the update file to the web application.
[0018] In a fifth aspect, the present invention further provides a computer device, comprising a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the web application code updating method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0019] In a sixth aspect, the present invention further provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the web application code updating method of the first aspect or any corresponding embodiment thereof.
[0020] In a seventh aspect, the present invention further provides a computer program product, comprising computer instructions, wherein the computer instructions are used to enable a computer to execute the web application code updating method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 is a flowchart of a method for updating a client webpage application code according to an embodiment of the present invention;
[0023] Figure 2 is a flowchart of an example of a method for updating a client webpage application code according to an embodiment of the present invention;
[0024] Figure 3 is a flow chart of a method for updating a server-side web application code according to an embodiment of the present invention;
[0025] Figure 4is a flowchart of an example of a method for updating a server-side web application code according to an embodiment of the present invention;
[0026] Figure 5 is a structural block diagram of a device for updating a client webpage application code according to an embodiment of the present invention;
[0027] Figure 6 is a structural block diagram of a server-side web application code updating device according to an embodiment of the present invention;
[0028] Figure 7 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0030] According to an embodiment of the present invention, an embodiment of a method for updating web application code is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0031] In this embodiment, a web application code update method is provided, which can be used on a client. Figure 1 is a flow chart of a method for updating client webpage application code according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0032] Step S101: intercepting a network request of a web application and determining a response method to the network request.
[0033] A web application is an application that can be accessed through the web. The biggest advantage of the program is that it is easy for users to access it. Users only need a browser and do not need to install other software. It is a typical product of the browser / server architecture.
[0034] In an optional implementation, Service Worker can be used to intercept network requests in web applications. In this embodiment, Service Worker is equivalent to the middleman role between the server and the browser. If Service Worker is registered in the website, it can intercept the website's requests. After the requests are intercepted, Service Worker can decide how to handle these requests, such as directly returning cached data, sending a request to the server to obtain data, or modifying or redirecting the request according to some rules.
[0035] For example, install and register Service Worker in the browser, notify the browser to allocate a block of memory for the page, and use the Service Worker Registration object in the entry JavaScript file to achieve this. Create a cache manifest (Cache Manifest), and use the Cache object in Service Worker to manage the cache. List the network resources that need to be cached for the website, generally including HTML, CSS, JavaScript, images, etc. Use the installed Service Worker to intercept the network request of the current web page and determine the response method to the network request.
[0036] In an optional implementation, determining the response method to the network request includes: when the resource file corresponding to the network request (generally including js and css files) is a static resource, the response method to the network request is to obtain the resource file in the current cache and return the resource file to the web application; when the resource file corresponding to the network request is not a static resource, the response method to the network request is to obtain the resource from the network. Generally, resources that do not change, such as pictures, fonts, and files, are static resources.
[0037] Step S102: When the response mode to the network request is to obtain resources from the network, it is determined whether the current cache contains a resource file corresponding to the network request.
[0038] Step S103: When the current cache contains a resource file corresponding to the network request, the current version number of the resource file is added to the network request and then sent to the server; when the current cache does not contain a file corresponding to the network request, the network request is sent to the server.
[0039] Step S104: Receive the response file returned by the server, and determine whether the resource file is a full file or an incremental update code file.
[0040] Step S105: when the resource file is an incremental update code file, the resource file is obtained in the current cache, the resource file is updated using the incremental update code file to obtain an update file, the current cache is updated using the update file, and the update file is returned to the web application.
[0041] In an optional implementation, when the resource file is a full file, the full file is used to update the current cache, and the full file is returned to the web application.
[0042] That is to say, the response file returned by the server is judged. If the response file is the full file of the resource file, the local file cache is directly updated with the response file, and the response file is returned to the web application. If the incremental update code file is returned, the resource file is first obtained from the cache, and then the incremental update code file is used to update the resource file to obtain the update file, and the update file is put back into the cache, and finally the update file is returned to the web application.
[0043] Figure 2 FIG. 1 is a flowchart of an example of a method for updating a client webpage application code according to an embodiment of the present invention. Figure 2 As shown, the client's web application code update method includes the following steps:
[0044] Step 1: When a user opens a web page in a browser and executes a network request for a file, Service Worker is used to intercept the network request and, based on the cache strategy of the web application, choose to directly use the resources in the cache, or add the current version number of the resource file to the network request and then obtain the resource from the network.
[0045] Step 2: After the browser receives the file returned by the server, it determines whether the resource file has been updated based on the response file returned by the server. If it has been updated, it determines whether the server has returned an incremental update code file or a full file based on the returned content. If it is determined to be a full file, the file currently cached by the client is cleared and the new version of the file is added to the cache. If it is determined to be an incremental update code file, the incremental update code file is used to update and upgrade the resource file cached in the current client to obtain a new version of the file, and the file is added to the cache.
[0046] Step 3: Service Worker returns the latest version of the file to the web application. In this way, the web application can use this new version of the file to update the user interface or provide updated content.
[0047] The webpage application code update method of the client provided in this embodiment intercepts the network request of the webpage application. When the response mode to the network request is to obtain resources from the network, the response file returned by the server is received, and it is determined whether the resource file is a full file or an incremental update code file; when the resource file is an incremental update code file, the resource file is obtained in the current cache, and the resource file is updated with the incremental update code file to obtain an update file, and the current cache is updated with the update file, and the update file is returned to the webpage application; thereby, the code is incrementally updated based on the original file, the amount of data to be transmitted is reduced, the webpage loading speed is accelerated, and the user experience is improved. At the same time, since only the incremental update code is transmitted, the network bandwidth occupation can also be reduced, the server load can be reduced, and the performance of the webpage application can be optimized.
[0048] In this embodiment, a web application code update method is provided, which can be used on the server side. Figure 3 is a flow chart of a method for updating a server-side web application code according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:
[0049] Step S301: receiving a network request sent by a client.
[0050] Step S302: Determine whether the network request contains the current version number of the resource file.
[0051] Step S303: When the network request includes the current version number of the resource file, the lowest version number corresponding to the resource file is obtained.
[0052] Step S304: When the current version number is higher than the minimum version number, the incremental update code file corresponding to the resource file is sent to the client; when the current version number is lower than the minimum version number, the full file corresponding to the resource file is sent to the client.
[0053] That is to say, a minimum version number that supports incremental updates is set for each resource file. Therefore, when a large number of resource file contents are updated, a full update can be directly adopted to avoid complex incremental calculations, thereby improving update efficiency.
[0054] For example, in a scenario where the content of a resource file has changed significantly, such as when a resource file has undergone a major modification from version v1.91 to v2.0, it may be more efficient to replace the entire file than to perform an incremental update. Therefore, the server will record that the minimum version number that supports incremental updates for the resource file is v2.0. When the client requests an update and the current version number of the resource file it carries is lower than v2.0, the server will provide the full file.
[0055] In order to conveniently maintain the minimum version number of each resource file, you can use a JSON file to store this information. For example, you can create a file named version.json, which contains the minimum version number that each resource file supports for incremental updates. When the server receives the client's network request, it compares the current version number in the client's network request with the minimum version number to decide whether to send the incremental update code file.
[0056] In an optional implementation, before sending the incremental update code file from the current version to the latest version corresponding to the resource file to the client, it also includes: determining whether there is an update script from the current version to the latest version; if so, using the update script as the incremental update code file; if not, concatenating multiple update scripts between the current version and the latest version to obtain an incremental update code file.
[0057] This is because, when the network request received by the server contains the current version number of the resource file, there are two situations: (1) the server has an incremental update code file from the current version to the latest version; (2) the server does not have an incremental update code file from the current version to the latest version.
[0058] For example, when the version of a resource file is upgraded from v1.11 to v1.12, the server will automatically generate an update script (v1.11-v1.12.js). Later, when the file is further upgraded to v1.13, the server will generate another update script (v1.12-v1.13.js). Considering that if there are clients still in version v1.11 and the server does not directly save the direct update file from v1.11 to v1.13, a merge process is required.
[0059] This merge process will merge the two update scripts v1.11-v1.12.js and v1.12-v1.13.js into a new update file, namely v1.11-v1.13.js. This newly generated update script is then returned to the v1.11 client that requested the upgrade and is stored on the server. In this way, when any client that is still in the v1.11 version requests an update in the future, the server can directly provide the merged v1.11-v1.13.js update file, thereby improving the update efficiency, reducing the client's waiting time, and optimizing the server's resource utilization.
[0060] Among them, the method for generating an update script includes: when monitoring that a resource file has been updated, obtaining the pre-update file and the post-update file of the resource file; converting both the pre-update file and the post-update file into an abstract syntax tree structure; performing a difference comparison between the pre-update file and the post-update file converted into the abstract syntax tree structure to obtain the update script of the resource file.
[0061] That is to say, monitor the update of resource files on the server side. For example, you can use Node.js's fs.watch on the server side to monitor the update of the target folder. These APIs allow us to detect the addition, modification or deletion of files in the folder in a timely manner. In order to conveniently monitor the update of resource files, you can set up a special folder on the server side to store resource files, and use fs.watch to monitor the changes of this folder.
[0062] When a file in a folder changes, fs.watch triggers a callback function that contains the event type and the file name that changed. We can determine the type of operation (create, modify, delete) based on the event type, and determine which file has changed based on the file name.
[0063] In order to track the version number of each resource file, we can add version information to the file name. For example, the file name format can be set to filename.v1.js, filename.v2.js, etc. In this way, every time we update the file, we only need to modify the version number in the file name.
[0064] When a resource file is changed, compare the code differences between the previous and next versions to generate an incremental update code file. In web applications, most of the changes are in JS files. For JS files, first convert the two JS files before and after the update into an AST (abstract syntax tree) structure. This can be achieved using libraries such as Esprima, Acorn, or Babel. Conversion of JS files to AST structures. In this process, comment nodes and empty nodes are ignored to reduce the workload of subsequent AST difference comparisons. Then compare the differences between the two ASTs, prioritize depth-first traversal to traverse the AST, compare the structure and attributes of each node, and record the code that needs to be updated.
[0065] In another optional implementation, when the network request does not include the current version number of the resource file, the full file of the latest version corresponding to the resource file is sent to the client.
[0066] Figure 4 FIG. 1 is a flow chart of an example of a method for updating a web application code on a server according to an embodiment of the present invention. Figure 4As shown, the web application code update method on the server side includes the following steps:
[0067] Step 1: Monitor the update of resource files on the server side, monitor the update of resource files in a timely manner, set the corresponding version number for each resource file, and set a minimum version number that supports incremental updates for each resource file.
[0068] Step 2: When it is found that the resource file has been updated, compare the code differences between the previous and later versions. Based on the parsing difference results, get the newly added, modified, and deleted codes in this file to get the update script.
[0069] Step 3: Based on the analysis results of step 2, generate an incremental update code file with a corresponding tag (such as v1.2-v1.3). The incremental update code file only contains incremental update code, which only contains the newly added, modified and deleted code parts, rather than the code of the entire file.
[0070] Step 4: Receive the client request and determine whether to return the corresponding incremental update code file or the full file to the client based on the client request and the policy configured on the server.
[0071] After receiving the file request, the server parses the file request and makes different responses based on the parsing results. There are five business scenarios in total.
[0072] Business scenario 1: The client's file request does not include file version information. This scenario is considered the first time the client has requested the file, and the server directly returns the latest version of the file.
[0073] Business scenario 2: The client's file request contains file version information, but the version is equal to or earlier than the minimum version number that the current version supports (for example, the current version that can support the incremental update code strategy is v2.0, but the file version information included in the file request is v1.1). In this scenario, it is determined that the current version cannot be upgraded through the incremental update code file, and the server returns the full file of the latest version to the client.
[0074] Business scenario 3: The file request from the client carries the file version information, and the server has an update code file from the version to the current latest version. The server returns the update code file to the client.
[0075] Business scenario 4: The client's file request contains file version information, but the server's update code folder does not currently contain an incremental update code file from the client's requested version to the current latest version. In this case, a new incremental update code file needs to be generated based on the server's needs. Generally speaking, the server needs to splice the update scripts to generate a new update code file (such as merging the v1.1-v1.2 update code file and the v1.2-v1.3 update code file into a v1.1-v1.3 update code file), and then save the file in the server's update code folder. The next time there is a client request for this version, business scenario 3 can be entered directly.
[0076] Business scenario 5: The client's file request contains file version information, and the file version is consistent with the latest file version. The server returns a response with a status code of 304, informing the client that the file is not currently updated and continues to use the file in the cache.
[0077] The web application code update method provided by the server side of this embodiment can realize incremental code update based on the original file, reduce the amount of data to be transmitted, speed up the web page loading speed, and improve the user experience. At the same time, since only the incremental update code is transmitted, the network bandwidth occupation can also be reduced, the server load can be reduced, and the performance of the web application can be optimized.
[0078] In this embodiment, a web application code update device is also provided, which is used to implement the above embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0079] This embodiment provides a web application code update device for a client, such as Figure 5 As shown, including:
[0080] The response mode determination module 501 is used to intercept the network request of the web application and determine the response mode to the network request.
[0081] The judgment module 502 is used to judge whether the current cache contains a resource file corresponding to the network request when the response mode to the network request is to obtain resources from the network.
[0082] The network request sending module 503 is used to add the current version number of the resource file in the network request and send it to the server when the current cache contains the resource file corresponding to the network request; when the current cache does not contain the file corresponding to the network request, send the network request to the server.
[0083] The response file receiving module 504 is used to receive the response file returned by the server and determine whether the resource file is a full file or an incremental update code file.
[0084] Processing module 505 is used to obtain the resource file in the current cache when the resource file is an incremental update code file, update the resource file using the incremental update code file to obtain an update file, update the current cache using the update file, and return the update file to the web application.
[0085] In some optional implementations, the response method determination module 501 is specifically used for: when the resource file corresponding to the network request is a static resource, the response method to the network request is to obtain the resource file in the current cache and return the resource file to the web application; when the resource file corresponding to the network request is not a static resource, the response method to the network request is to obtain the resource from the network.
[0086] This embodiment provides a web application code update device at a server end, such as Figure 6 As shown, including:
[0087] The network request receiving module 601 is used to receive a network request sent by a client.
[0088] The determination module 602 is used to determine whether the network request contains the current version number of the resource file.
[0089] The minimum version number acquisition module 603 is used to acquire the minimum version number corresponding to the resource file when the network request includes the current version number of the resource file.
[0090] The sending module 604 is used to send the incremental update code file corresponding to the resource file to the client when the current version number is higher than the minimum version number; when the current version number is lower than the minimum version number, send the full file corresponding to the resource file to the client.
[0091] In some optional implementations, the web application code update device of the server also includes an incremental update code file generation module. Before sending the incremental update code file corresponding to the resource file from the current version to the latest version to the client, the incremental update code file generation module is used to: determine whether there is an update script from the current version to the latest version; if it exists, use the update script as the incremental update code file; if it does not exist, splice multiple update scripts between the current version and the latest version to obtain an incremental update code file; wherein the update script generation method includes: when monitoring that the resource file has been updated, obtain the pre-update file and the post-update file of the resource file; convert the pre-update file and the post-update file into an abstract syntax tree structure; compare the pre-update file and the post-update file converted into the abstract syntax tree structure to obtain the update script of the resource file.
[0092] In some optional implementations, the sending module 604 is further used to: when the network request does not include the current version number of the resource file, send the full file of the latest version corresponding to the resource file to the client.
[0093] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0094] The web application code update device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0095] The embodiment of the present invention also provides a computer device having the above Figure 5 and / or Figure 6 The web application code updating device is shown.
[0096] See also Figure 7 , Figure 7 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 7As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 7 A processor 10 is taken as an example.
[0097] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0098] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.
[0099] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0100] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0101] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 7 The example of connecting through bus is taken in the following.
[0102] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.
[0103] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0104] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0105] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. A web application code update method, applied to a server, characterized in that: include: Receive network requests sent by clients; Determine whether the network request contains the current version number of the resource file; When the network request contains the current version number of the resource file, obtaining the lowest version number corresponding to the resource file; When the current version number is higher than the minimum version number, the incremental update code file corresponding to the resource file is sent to the client; when the current version number is lower than the minimum version number, the full file corresponding to the resource file is sent to the client.
2. The method according to claim 1, characterized in that Before sending the incremental update code file corresponding to the resource file from the current version to the latest version to the client, the method further includes: Determine whether there is an update script from the current version to the latest version; When it exists, the update script is used as the incremental update code file; If it does not exist, multiple update scripts between the current version and the latest version are spliced to obtain the incremental update code file and save it; Among them, the method for generating the update script includes: when monitoring that a resource file is updated, obtaining the pre-update file and the post-update file of the resource file; converting the pre-update file and the post-update file into an abstract syntax tree structure; performing a difference comparison between the pre-update file and the post-update file converted into the abstract syntax tree structure to obtain the update script of the resource file.
3. The method according to claim 1, characterized in that Also includes: When the network request does not include the current version number of the resource file, the full file of the latest version corresponding to the resource file is sent to the client.
4. A web application code update method, applied to a client, characterized in that: include: Intercepting network requests from web applications and determining a response method to the network requests; When the response mode to the network request is to obtain resources from the network, determining whether the current cache contains a resource file corresponding to the network request; When the current cache contains a resource file corresponding to the network request, the current version number of the resource file is added to the network request and then sent to the server; when the current cache does not contain a file corresponding to the network request, the network request is sent to the server; Receive the response file returned by the server, and determine whether the resource file is a full file or an incremental update code file; When the resource file is the incremental update code file, the resource file is obtained in the current cache, the resource file is updated using the incremental update code file to obtain an update file, the current cache is updated using the update file, and the update file is returned to the web application.
5. The method according to claim 4, characterized in that The determining of a response mode to the network request includes: When the resource file corresponding to the network request is a static resource, the response to the network request is to obtain the resource file in the current cache and return the resource file to the web application; When the resource file corresponding to the network request does not belong to the static resource, the response to the network request is to obtain the resource from the network.
6. A web application code updating device, applied to a server, characterized in that: include: A network request receiving module, used to receive a network request sent by a client; A determination module, used to determine whether the network request contains the current version number of the resource file; A minimum version number acquisition module, used for acquiring the minimum version number corresponding to the resource file when the network request contains the current version number of the resource file; A sending module is used to send the incremental update code file corresponding to the resource file to the client when the current version number is higher than the minimum version number; when the current version number is lower than the minimum version number, send the full file corresponding to the resource file to the client.
7. A web application code updating device, applied to a client, characterized in that: include: A response mode determination module, used to intercept the network request of the web application and determine the response mode to the network request; A judgment module, used for judging whether the current cache contains a resource file corresponding to the network request when the response mode to the network request is to obtain resources from the network; A network request sending module, configured to, when the current cache contains a resource file corresponding to the network request, add the current version number of the resource file to the network request and then send it to the server; when the current cache does not contain a file corresponding to the network request, send the network request to the server; A response file receiving module, used to receive the response file returned by the server, and determine whether the resource file is a full file or an incremental update code file; A processing module is used to obtain the resource file in the current cache when the resource file is the incremental update code file, update the resource file using the incremental update code file to obtain an update file, update the current cache using the update file, and return the update file to the web application.
8. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the web application code updating method according to any one of claims 1 to 5 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the web application code updating method according to any one of claims 1 to 5.
10. A computer program product, characterized in that The method comprises computer instructions, wherein the computer instructions are used to cause a computer to execute the web application code updating method according to any one of claims 1 to 5.