CN111475180A - Method and system for updating client cache - Google Patents

Method and system for updating client cache Download PDF

Info

Publication number
CN111475180A
CN111475180A CN201910068527.0A CN201910068527A CN111475180A CN 111475180 A CN111475180 A CN 111475180A CN 201910068527 A CN201910068527 A CN 201910068527A CN 111475180 A CN111475180 A CN 111475180A
Authority
CN
China
Prior art keywords
cache
resource file
management module
cache management
server
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910068527.0A
Other languages
Chinese (zh)
Inventor
卢晶晶
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910068527.0A priority Critical patent/CN111475180A/en
Publication of CN111475180A publication Critical patent/CN111475180A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates

Abstract

The invention discloses a method and a system for updating client cache, and relates to the technical field of computers. One embodiment of the method comprises: the browser registers the page of the unregistered cache management module according to the page access request and installs the cache management module; the cache management module searches the requested resource file from the cache according to the page access request, and executes the resource file to send an update verification request to the server, wherein the update verification request comprises a version identifier of the resource file; the server verifies whether the resource file is updated according to the version identification and returns a verification result to the cache management module; and the cache management module judges according to the verification result, and if the resource file is updated, the latest resource file is requested to the server through the update cache management module, and the resource file in the cache is updated. According to the embodiment, the file name of the resource file is not required to be modified, and the short caching time is not required to be set for the resource file, so that the cache can be updated in time.

Description

Method and system for updating client cache
Technical Field
The invention relates to the technical field of computers, in particular to a method and a system for updating client cache.
Background
The browser caching means that the browser stores requested resource files (such as JavaScript script files, CSS cascading style sheet files, picture files and the like) to the local part of the client by using a caching mechanism of an HTTP (Hypertext Transfer Protocol) Protocol, and when a next request comes, the browser can directly load resources meeting caching conditions from the local part of the client.
The method comprises the steps of establishing a cache, establishing a policy for storing a resource, and storing the policy in a cache server, wherein the policy comprises a client side, a browser cache, a negotiation cache, a server cache, a negotiation cache policy, a communication policy and a server cache.
However, in the process of implementing the present invention, the inventor finds that at least the following problems still exist in the prior art:
1. cache updates implemented by changing filenames are not appropriate for all files:
(1) some third-party static resource files are referenced by a plurality of developers, and updating by modifying file names cannot guarantee that all developers know the files, which is inconvenient. The caching strategy of the third-party script is to adopt forced caching and set a short expiration time so as to update the caching in time. However, the method cannot ensure that the next request of the client is the latest resource after the server file is updated;
(2) for a blog website, a user generally cannot modify a page source code, and cannot update the cache in a manner of updating a resource file name;
2. the current mainstream development mode is front-end separation, the HTM L page and the static file are usually deployed on different servers, both sides need to be deployed during updating every time, and the deployment cost is increased.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and a system for updating a client cache, which can manage and update a cache file at a client, and can implement timely updating of a cache without modifying a file name of a resource file or setting a short cache time for the resource file, thereby ensuring that a resource file of a user request page acquired by a browser each time is a latest version.
To achieve the above object, according to an aspect of the embodiments of the present invention, a method for updating a client cache is provided.
A method of updating a client cache, comprising: the browser registers the page of the unregistered cache management module according to the page access request and installs the cache management module; the cache management module searches a requested resource file from a cache according to the page access request, and executes the resource file to send an update verification request to a server, wherein the update verification request comprises a version identifier of the resource file; the server verifies whether the resource file is updated according to the version identification and returns a verification result to the cache management module; and the cache management module judges according to the verification result, and if the resource file is updated, the cache management module is updated to request the latest resource file from the server and update the resource file in the cache.
Optionally, the method further comprises: and setting the caching strategy of the updating verification request as never caching so that the updating verification request is sent every time the resource file is executed.
Optionally, the method further comprises: and if the cache management module does not find the resource file from the cache, directly requesting the server to acquire the resource file.
Optionally, the updating the cache management module to request the latest resource file from the server includes: and triggering the browser to update the cache management module by changing the cached version identifier so that the updated cache management module directly requests the server for the latest resource file.
Optionally, the method further comprises: and setting the cache strategy of the request of the cache management module in the installation process as never caching so as to directly send the request in the installation process to the server.
Optionally, the cache management module is a Service Worker.
According to another aspect of the embodiments of the present invention, a system for updating a client cache is provided.
A system for updating a client cache, comprising: the system comprises a browser, a cache management module and a server, wherein the browser is used for registering a page of the unregistered cache management module and installing the cache management module according to a page access request; the cache management module is used for searching a requested resource file from a cache according to the page access request and executing the resource file to send an update verification request to a server, wherein the update verification request comprises a version identifier of the resource file; after receiving a verification result returned by the server, judging according to the verification result, if the resource file is updated, updating the cache management module to request the latest resource file from the server, and updating the resource file in the cache; the server is used for verifying whether the resource file is updated according to the version identification and returning a verification result to the cache management module.
Optionally, the update verification request is sent each time the resource file is executed by setting the caching policy of the update verification request as never cached.
Optionally, if the cache management module does not find the resource file from the cache, directly requesting the server to obtain the resource file.
Optionally, the cache management module is further configured to: and triggering the browser to update the cache management module by changing the cached version identifier so that the updated cache management module directly requests the server for the latest resource file.
Optionally, the cache policy of the request of the cache management module in the installation process is set as never-caching, so that the request in the installation process is directly sent to the server.
Optionally, the cache management module is a Service Worker.
According to another aspect of the embodiment of the invention, an electronic device for updating a client cache is provided.
An electronic device to update a client cache, comprising: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method for updating the client cache provided by the embodiment of the invention.
According to yet another aspect of embodiments of the present invention, a computer-readable medium is provided.
A computer readable medium, on which a computer program is stored, which when executed by a processor implements a method of updating a client cache as provided by an embodiment of the invention.
One embodiment of the above invention has the following advantages or benefits: controlling and updating the cache at the client by introducing a cache management module, recording a version identifier in a resource file needing to be cached, sending an update verification request to inform a server of the version identifier when executing the resource file each time, comparing the received version identifier with the version identifier of the latest resource file by the server, judging whether the update exists or not, and informing the cache management module; if the cache management module receives the update information, the latest resource file is requested to the server through the update cache management module, so that the management and the update of the cache file at the client are realized, the file name of the resource file is not required to be modified, the short cache time is not required to be set for the resource file, and the timely update of the cache can be realized, thereby ensuring that the resource file of the user request page acquired by the browser each time is the latest version. In addition, the invention can avoid the problem of untimely resource updating caused by the caching of the ServiceWorker installation file by carrying out version control on the cache name.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram illustrating the main steps of a method for updating a client cache according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of the main components of a system for updating client caches in accordance with an embodiment of the present invention;
fig. 3 is a schematic flow chart illustrating an implementation of a client cache updating method according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 5 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
In order to solve the problems in the prior art, the invention provides a method and a system for updating a cache file at a client, which can realize the timely updating of the cache without modifying the file name or setting short cache time for the file. Since the browser cache generally refers to an HTTP cache, in order to distinguish, the cache in the browser of the client in the present invention is referred to as a client cache, which is simply referred to as "cache".
In describing the embodiments of the present invention, the terms appearing are defined as follows:
static resource files: a client sends a request to a Web (World Wide Web) server, the Web server acquires a corresponding file from a file system, the corresponding file is directly returned to the client, and the client analyzes, renders and displays the file, wherein the file is generally called a static resource, and is generally a file generated by dynamic operation of non-servers such as JS (JavaScript for short), CSS (Cascading Styles lists), pictures and the like;
service Worker: the service thread is a script which is operated by the browser independently of the web page in the background, and provides the capability of silently executing the functions which do not need to interact with the web page at the back of the web page. The JavaScript operating thread is a programmable network agent, and a developer can control the processing mode of a network request sent by a page. The ServiceWorker firstly has the functions of intercepting and processing network requests, including programmable message cache management capability.
The principle of the invention is as follows: the method comprises the steps of controlling and updating a cache at a client by introducing a cache management module Service Worker, recording version identification in a static resource file needing to be cached, sending an update verification request to inform a server of the version identification when executing the static resource file each time, comparing the received version identification with the version identification of the latest resource file by the server, judging whether the update exists or not, and informing the cache management module Service Worker. If the cache management module Service Worker receives the update information, the cache version number of the cache management module Service Worker is changed to trigger the browser to update the Service Worker, and the updated cache management module Service Worker requests the latest resource file. According to the technical scheme of the invention, the timely cache updating is realized, and the file name of the resource file is not required to be modified.
In order to implement the technical scheme of the invention, the version identification can be added in the static resource files needing to be cached in advance, and the static resource files are set to send an updating verification request to the server when being executed so as to verify whether the static resource files locally cached by the client are the latest version. The version identifier is any data that can identify the current version of the static resource file, such as a version number or a timestamp. In addition, the caching strategy of each resource can be preset: (1) setting an update verification request for acquiring file update information to be directly sent to a server without caching; (2) and setting the static resource file as cache priority, and if no result is found in the cache, sending the result to the server.
According to the technical scheme of the invention, the cache management module is, for example, a Service work thread Worker. When a user requests to access a page, the browser registers a Service Worker for the page by calling a navigator. Specifically, the browser can be informed of the specific location of the Service Worker script by executing the code of the registered Service Worker deployed in the page.
After registering the Service Worker for the page, the browser finds the Service Worker script file from the specific location where the Service Worker script is placed, loads it into the browser and executes to install the Service Worker. In the install callback event handling function, the Service Worker may request a resource (e.g., JS file, etc.) to be cached, open a cache, set a cache name, set a cache policy, and the like. When the cache name is set, the current version identifier (for example, version number, timestamp, etc.) of the cache may be used as the cache name and saved by using the variable version. When the cache is changed, the cached change can be identified by modifying the cached version identification, so that the browser can timely find that the Service Worker is modified, update the Service Worker and reinstall the Service Worker. By carrying out version control on the cache name, the problem that resource updating is not timely caused by the fact that the Service Worker installation file is cached can be solved.
Meanwhile, in order to avoid loading static resource files of other page access requests sent by a user in the Service Worker installation process from a browser cache (namely an HTTP cache), the cache policy of the requests in the Service Worker installation process can be set to be never cached, for example, a request parameter { cache: 'no-cache' } can be set to ensure that the requests must be verified to a server side. For example: and setting new Request ('/script. js ', { cache: ' no-cache ' }) so that the acquisition Request of the static resource file of "/script. js ' is directly verified to the server.
And finally, after the Service Worker is installed, intercepting the network requests through a fetch event of the Service Worker, and responding each intercepted request according to a preset response rule for the request. The preset response rule to the request is, for example: if the request is a page access request, searching a resource file of the request from a cache according to the page access request in priority; if the request is the version identification of the resource file returned by the server, judging according to the version identification, if the resource file is not updated (the version identification is the same), sending the cached resource file to the browser, and if the resource file is updated (the version identification is different), updating the Service Worker by modifying the cache name (or the cached version identification or the version identification of the resource file in the cached resource list) so as to request to acquire the latest resource file from the server.
Fig. 1 is a schematic diagram illustrating the main steps of a method for updating a client cache according to an embodiment of the present invention. As shown in fig. 1, the method for updating a client cache according to the embodiment of the present invention mainly includes the following steps S101 to S104.
Step S101: the browser registers the page of the unregistered cache management module according to the page access request and installs the cache management module;
step S102: the cache management module searches the requested resource file from the cache according to the page access request, and executes the resource file to send an update verification request to the server, wherein the update verification request comprises a version identifier of the resource file;
step S103: the server verifies whether the resource file is updated according to the version identification and returns a verification result to the cache management module;
step S104: and the cache management module judges according to the verification result, and if the resource file is updated, the latest resource file is requested to the server through the update cache management module, and the resource file in the cache is updated.
According to the embodiment of the invention, the caching strategy of the update checking request is set to be never cached, so that the update checking request is sent every time the resource file is executed. Therefore, the static resource files of the user request page acquired by the browser each time are all the latest version.
According to an embodiment of the present invention, if the cache management module does not find the resource file from the cache, the cache management module directly requests the server to obtain the resource file. If the resource file is not found in the cache, it indicates that the file is not cached or the cache is expired, and therefore, the latest file needs to be requested from the server, so that the file included in the page displayed by the browser each time is the latest version of the file.
According to another embodiment of the present invention, requesting the latest resource file from the server by updating the cache management module may include, when executing: and triggering the browser to update the cache management module by changing the cached version identifier so that the updated cache management module directly requests the latest resource file from the server. By carrying out version control on the cache name, the problem that resource updating is not timely caused by the fact that the Service Worker installation file is cached can be solved.
According to one embodiment of the invention, the cache policy of the request of the cache management module in the installation process is set to be never cached, so that the request in the installation process is directly sent to the server. Therefore, the problem that the page file displayed to the user is not necessarily the latest version due to the loading of the resource file from the browser cache (namely HTTP cache) when the user sends other page access requests in the installation process of the cache management module can be avoided, and the accuracy of the page file displayed to the user at any time is ensured.
In the embodiment of the invention, the cache management module is a Service Worker.
Fig. 2 is a schematic diagram of main components of a system for updating a client cache according to an embodiment of the present invention. As shown in fig. 2, a system 200 for updating a client cache according to an embodiment of the present invention mainly includes a browser 201, a cache management module 202, and a server 203. The browser 201 and the cache management module 202 are located at a client, and the server 203 is located at a server.
The browser 201 is configured to register a page of the unregistered cache management module according to the page access request and install the cache management module;
the cache management module 202 is configured to search a requested resource file from a cache according to the page access request, and execute the resource file to send an update check request to the server, where the update check request includes a version identifier of the resource file; after receiving the verification result returned by the server, judging according to the verification result, if the resource file is updated, requesting the latest resource file from the server through the updating cache management module, and updating the resource file in the cache;
the server 203 is configured to verify whether the resource file is updated according to the version identifier, and return a verification result to the cache management module.
According to one embodiment of the invention, the caching policy of the update checking request is set to be never cached, so that the update checking request is sent every time the resource file is executed.
According to another embodiment of the present invention, if the cache management module does not find the resource file from the cache, the cache management module directly requests the server to obtain the resource file.
According to another embodiment of the present invention, the cache management module 202 may further be configured to:
and triggering the browser to update the cache management module by changing the cached version identifier so that the updated cache management module directly requests the latest resource file from the server.
According to another embodiment of the invention, the request in the installation process is directly sent to the server by setting the caching policy of the request in the installation process of the cache management module as never caching.
In the embodiment of the invention, the cache management module is a Service work thread Worker.
Fig. 3 is a schematic flow chart illustrating an implementation of the client cache updating method according to the embodiment of the present invention. As shown in fig. 3, the client cache updating method according to the embodiment of the present invention mainly includes the following implementation steps:
step S1: a user requests to open a page in a browser;
step S2: the browser judges whether the page is registered with the Service Worker. If so, executing step S6, otherwise, executing step S3;
step S3: the browser registers the Service Worker for the page, and specifically, the storage position of the Service Worker script can be obtained by executing the code of the registered Service Worker in the page;
step S4: the browser downloads and executes the Service Worker script file;
step S5: installing a Service Worker, and requesting and caching a required static resource file from a server by installing a callback event processing function;
step S6: and after the Service Worker is installed, judging whether the cache has the static resource file requested by the user. If yes, executing step S8, otherwise, executing step S7;
step S7: requesting the latest static resource file from the server, and then performing step S8;
step S8: the Service Worker executes the corresponding static resource file and sends an updating verification request;
step S9: intercepting a verification result returned by a server by a catch method of a Service Worker;
step S10: and the Service Worker judges whether the static resource file is updated according to the verification result. If not, executing step S11, otherwise executing step S12;
step S11: returning the static resource file cached in the Service Worker installation stage to the browser;
step S12: and changing the cache version number of the Service Worker to trigger the browser to execute the step S5.
According to the technical scheme of the embodiment of the invention, a cache management module is introduced to control and update the cache at a client, version identification is recorded in a resource file needing to be cached, an update verification request is sent to inform a server of the version identification when the resource file is executed each time, the server compares the received version identification with the version identification of the latest resource file, judges whether the update exists or not, and informs the cache management module; if the cache management module receives the update information, the latest resource file is requested to the server through the update cache management module, so that the management and the update of the cache file at the client are realized, the file name of the resource file is not required to be modified, the short cache time is not required to be set for the resource file, and the timely update of the cache can be realized, thereby ensuring that the resource file of the user request page acquired by the browser each time is the latest version. In addition, the invention can avoid the problem of untimely resource updating caused by the cache of the Service Worker installation file by carrying out version control on the cache name.
Fig. 4 illustrates an exemplary system architecture 400 of a system for updating a client cache or a method of updating a client cache to which embodiments of the present invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like. The terminal devices 401, 402, 403 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 401, 402, 403 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 405 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 401, 402, 403. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the method for updating the client cache provided by the embodiment of the present invention is generally executed by the server 405, and accordingly, a system for updating the client cache is generally disposed in the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, a block diagram of a computer system 500 suitable for use with a terminal device or server implementing an embodiment of the invention is shown. The terminal device or the server shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
To the I/O interface 505, AN input section 506 including a keyboard, a mouse, and the like, AN output section 507 including a keyboard such as a Cathode Ray Tube (CRT), a liquid crystal display (L CD), and the like, a speaker, and the like, a storage section 508 including a hard disk and the like, and a communication section 509 including a network interface card such as a L AN card, a modem, and the like, the communication section 509 performs communication processing via a network such as the internet, a drive 510 is also connected to the I/O interface 505 as necessary, a removable medium 511 such as a magnetic disk, AN optical disk, a magneto-optical disk, a semiconductor memory, and the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units or modules described in the embodiments of the present invention may be implemented by software, or may be implemented by hardware.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: the browser registers the page of the unregistered cache management module according to the page access request and installs the cache management module; the cache management module searches a requested resource file from a cache according to the page access request, and executes the resource file to send an update verification request to a server, wherein the update verification request comprises a version identifier of the resource file; the server verifies whether the resource file is updated according to the version identification and returns a verification result to the cache management module; and the cache management module judges according to the verification result, and if the resource file is updated, the cache management module is updated to request the latest resource file from the server and update the resource file in the cache.
According to the technical scheme of the embodiment of the invention, a cache management module is introduced to control and update the cache at a client, version identification is recorded in a resource file needing to be cached, an update verification request is sent to inform a server of the version identification when the resource file is executed each time, the server compares the received version identification with the version identification of the latest resource file, judges whether the update exists or not, and informs the cache management module; if the cache management module receives the update information, the latest resource file is requested to the server through the update cache management module, so that the management and the update of the cache file at the client are realized, the file name of the resource file is not required to be modified, the short cache time is not required to be set for the resource file, and the timely update of the cache can be realized, thereby ensuring that the resource file of the user request page acquired by the browser each time is the latest version. In addition, the invention can avoid the problem of untimely resource updating caused by the cache of the Service Worker installation file by carrying out version control on the cache name.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (14)

1. A method for updating a client cache, comprising:
the browser registers the page of the unregistered cache management module according to the page access request and installs the cache management module;
the cache management module searches a requested resource file from a cache according to the page access request, and executes the resource file to send an update verification request to a server, wherein the update verification request comprises a version identifier of the resource file;
the server verifies whether the resource file is updated according to the version identification and returns a verification result to the cache management module;
and the cache management module judges according to the verification result, and if the resource file is updated, the cache management module is updated to request the latest resource file from the server and update the resource file in the cache.
2. The method of claim 1, further comprising: and setting the caching strategy of the updating verification request as never caching so that the updating verification request is sent every time the resource file is executed.
3. The method of claim 1, further comprising: and if the cache management module does not find the resource file from the cache, directly requesting the server to acquire the resource file.
4. The method of claim 1, wherein updating the cache management module to request the latest resource file from the server comprises:
and triggering the browser to update the cache management module by changing the cached version identifier so that the updated cache management module directly requests the server for the latest resource file.
5. The method of claim 1, further comprising: and setting the cache strategy of the request of the cache management module in the installation process as never caching so as to directly send the request in the installation process to the server.
6. The method of claim 1, wherein the cache management module is a Service Worker.
7. A system for updating a client cache, comprising: a browser, a cache management module, and a server, wherein,
the browser is used for registering the page of the unregistered cache management module according to the page access request and installing the cache management module;
the cache management module is used for searching a requested resource file from a cache according to the page access request and executing the resource file to send an update verification request to a server, wherein the update verification request comprises a version identifier of the resource file; after receiving a verification result returned by the server, judging according to the verification result, if the resource file is updated, updating the cache management module to request the latest resource file from the server, and updating the resource file in the cache;
the server is used for verifying whether the resource file is updated according to the version identification and returning a verification result to the cache management module.
8. The system of claim 7, wherein the update checking request is sent each time the resource file is executed by setting a caching policy of the update checking request to be never cached.
9. The system according to claim 7, wherein if the cache management module does not find the resource file from the cache, directly requesting the server to obtain the resource file.
10. The system of claim 7, wherein the cache management module is further configured to:
and triggering the browser to update the cache management module by changing the cached version identifier so that the updated cache management module directly requests the server for the latest resource file.
11. The system according to claim 7, wherein the request during installation is sent directly to the server by setting the caching policy of the request during installation of the cache management module as never caching.
12. The system of claim 7, wherein the cache management module is a Service Worker.
13. An electronic device for updating a client cache, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-6.
14. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-6.
CN201910068527.0A 2019-01-24 2019-01-24 Method and system for updating client cache Pending CN111475180A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910068527.0A CN111475180A (en) 2019-01-24 2019-01-24 Method and system for updating client cache

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910068527.0A CN111475180A (en) 2019-01-24 2019-01-24 Method and system for updating client cache

Publications (1)

Publication Number Publication Date
CN111475180A true CN111475180A (en) 2020-07-31

Family

ID=71743549

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910068527.0A Pending CN111475180A (en) 2019-01-24 2019-01-24 Method and system for updating client cache

Country Status (1)

Country Link
CN (1) CN111475180A (en)

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112637262A (en) * 2020-11-18 2021-04-09 网宿科技股份有限公司 Content pushing method and device
CN112926002A (en) * 2021-03-10 2021-06-08 工银科技有限公司 Service request processing method and device
CN112925539A (en) * 2021-02-19 2021-06-08 天津车之家数据信息技术有限公司 Application updating method, computing device and storage medium
CN113360464A (en) * 2021-06-10 2021-09-07 山东云缦智能科技有限公司 Cache synchronization method for realizing OSS based on Nginx
CN113392078A (en) * 2021-06-04 2021-09-14 上海浦东发展银行股份有限公司 Method and device for monitoring operation change state, computer equipment and storage medium
CN113407876A (en) * 2021-06-18 2021-09-17 杭州安恒信息技术股份有限公司 Webpage refreshing method, webpage refreshing system and related device
CN113641932A (en) * 2021-06-23 2021-11-12 福建野小兽健康科技有限公司 Page updating method and system based on H5
CN113672268A (en) * 2021-06-18 2021-11-19 杭州玳数科技有限公司 Silent updating method and device for front-end resources and computer equipment
CN113779458A (en) * 2021-07-27 2021-12-10 北京房江湖科技有限公司 Method and device for accelerating application loading, electronic equipment and storage medium
CN114584543A (en) * 2022-02-16 2022-06-03 百安居信息技术(上海)有限公司 Web-based resource quick access method, system, medium and equipment
CN114936192A (en) * 2022-07-19 2022-08-23 成都新橙北斗智联有限公司 Method and system for dynamically compressing, obfuscating and bidirectionally caching files
CN115242775A (en) * 2022-07-04 2022-10-25 中国银联股份有限公司 Resource file acquisition method, device, equipment, medium and product
CN116244538A (en) * 2023-01-31 2023-06-09 彭志勇 File caching method and loading method based on serviceworker

Cited By (17)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112637262A (en) * 2020-11-18 2021-04-09 网宿科技股份有限公司 Content pushing method and device
CN112925539B (en) * 2021-02-19 2022-12-06 天津车之家数据信息技术有限公司 Application updating method, computing device and storage medium
CN112925539A (en) * 2021-02-19 2021-06-08 天津车之家数据信息技术有限公司 Application updating method, computing device and storage medium
CN112926002A (en) * 2021-03-10 2021-06-08 工银科技有限公司 Service request processing method and device
CN113392078A (en) * 2021-06-04 2021-09-14 上海浦东发展银行股份有限公司 Method and device for monitoring operation change state, computer equipment and storage medium
CN113360464A (en) * 2021-06-10 2021-09-07 山东云缦智能科技有限公司 Cache synchronization method for realizing OSS based on Nginx
CN113407876A (en) * 2021-06-18 2021-09-17 杭州安恒信息技术股份有限公司 Webpage refreshing method, webpage refreshing system and related device
CN113672268A (en) * 2021-06-18 2021-11-19 杭州玳数科技有限公司 Silent updating method and device for front-end resources and computer equipment
CN113641932A (en) * 2021-06-23 2021-11-12 福建野小兽健康科技有限公司 Page updating method and system based on H5
CN113779458A (en) * 2021-07-27 2021-12-10 北京房江湖科技有限公司 Method and device for accelerating application loading, electronic equipment and storage medium
CN113779458B (en) * 2021-07-27 2024-02-27 贝壳找房(北京)科技有限公司 Method and device for accelerating application loading, electronic equipment and storage medium
CN114584543A (en) * 2022-02-16 2022-06-03 百安居信息技术(上海)有限公司 Web-based resource quick access method, system, medium and equipment
CN115242775A (en) * 2022-07-04 2022-10-25 中国银联股份有限公司 Resource file acquisition method, device, equipment, medium and product
CN114936192A (en) * 2022-07-19 2022-08-23 成都新橙北斗智联有限公司 Method and system for dynamically compressing, obfuscating and bidirectionally caching files
CN114936192B (en) * 2022-07-19 2022-10-28 成都新橙北斗智联有限公司 Method and system for dynamic compression confusion and bidirectional caching of files
CN116244538A (en) * 2023-01-31 2023-06-09 彭志勇 File caching method and loading method based on serviceworker
CN116244538B (en) * 2023-01-31 2023-11-21 彭志勇 File caching method and loading method based on serviceworker

Similar Documents

Publication Publication Date Title
CN111475180A (en) Method and system for updating client cache
US9182975B2 (en) Automatic application updates
US11563674B2 (en) Content based routing method and apparatus
US8667480B1 (en) Automatically updating browser extensions, and applications thereof
CN107844324B (en) Client page jump processing method and device
CN111427701A (en) Workflow engine system and business processing method
CN107644075B (en) Method and device for collecting page information
CN107809470B (en) Method and device for automatically deploying application program
CN112269959A (en) Display content control method and device, readable medium and electronic equipment
CN110365745B (en) Data processing system, method, apparatus, server and computer readable medium
CN113364887B (en) File downloading method based on FTP, proxy server and system
CN112748962B (en) Application loading method, device, electronic equipment and computer readable medium
CN111783005B (en) Method, device and system for displaying web page, computer system and medium
CN113360815A (en) Request retry method and device
CN109981546B (en) Method and device for acquiring remote call relation between application modules
CN110851194A (en) Method and device for acquiring code for realizing new interface
CN114115941A (en) Resource sending method, page rendering method, device, electronic equipment and medium
CN109547552B (en) API request processing method and device, storage medium and electronic equipment
CN113742617A (en) Cache updating method and device
CN113296829A (en) Method, device, equipment and computer readable medium for processing service
CN108833147B (en) Configuration information updating method and device
US20140164556A1 (en) Method and system for live loading of a toolbar
CN112579447A (en) Browser testing method and device
CN113132447A (en) Reverse proxy method and system
CN112835609A (en) Method and device for modifying dependent package download address

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination