CN113703807A - Method and system for detecting and updating static resource version in real time - Google Patents

Method and system for detecting and updating static resource version in real time Download PDF

Info

Publication number
CN113703807A
CN113703807A CN202110988918.1A CN202110988918A CN113703807A CN 113703807 A CN113703807 A CN 113703807A CN 202110988918 A CN202110988918 A CN 202110988918A CN 113703807 A CN113703807 A CN 113703807A
Authority
CN
China
Prior art keywords
static resource
version number
page
file
active state
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.)
Granted
Application number
CN202110988918.1A
Other languages
Chinese (zh)
Other versions
CN113703807B (en
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.)
Shanghai Datatom Information Technology Co ltd
Original Assignee
Shanghai Datatom 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 Shanghai Datatom Information Technology Co ltd filed Critical Shanghai Datatom Information Technology Co ltd
Priority to CN202110988918.1A priority Critical patent/CN113703807B/en
Publication of CN113703807A publication Critical patent/CN113703807A/en
Application granted granted Critical
Publication of CN113703807B publication Critical patent/CN113703807B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method and a system for detecting and updating a static resource version in real time, wherein the method comprises the following steps of obtaining all static resource files, and processing all the static resource files to obtain a text file of the static resource version number; when a page is initialized, loading a stored static resource version number file from a server; judging whether the page is in an active state; if the page is not in an active state, no operation is performed; if the page is in an active state, acquiring a static resource version number file and extracting a version number in the static resource version number file; comparing the version number with the static resource version number in the static resource version number text file to judge whether the version number is consistent with the static resource version number; if the static resource files are consistent, judging that the static resource files are not changed, and returning to execute the step A3; if the static resource files are inconsistent, judging that the static resource files are updated, and prompting a user to refresh the page through a resident displayed notification bar; the system comprises a construction module, a state detection module, a comparison module and a prompt module.

Description

Method and system for detecting and updating static resource version in real time
Technical Field
The invention relates to the field of real-time detection and updating of static resource versions, in particular to a method and a system for real-time detection and updating of static resource versions.
Background
When the web end application is used, the static resource usually uses a cache strategy to reduce bandwidth consumption, meanwhile, the request speed is accelerated, for the static resource using strong cache, a web front end browser can preferentially read a copy of the static resource stored this time, even if the program version of a server is updated, the browser cannot sense the static resource without refreshing a page, and the static resource of an old version can still be loaded.
Disclosure of Invention
The invention aims to solve the technical problem that a browser cannot sense the update of a static resource copy read by a web front-end browser and a program version of a server under the condition of not refreshing a page, and the old version of static resources can be loaded at the moment, and the invention provides a method for detecting and updating the version of the static resources in real time, and also provides a system for detecting and updating the version of the static resources in real time, which can generate a text file of the version number of the static resources for the static resources in a construction period, detect the version of the version number of the static resources in the static resources file of the server at regular time and compare the version number with the loaded version number of the current page at a running period if the page is active, and prompt a user to refresh the page if the version number is inconsistent, thereby effectively avoiding a series of errors and crashes caused by untimely update of the static resources file relative to the page without the technical scheme, and the waste of performance and bandwidth is avoided, so that the defects caused by the prior art are overcome.
In order to solve the technical problems, the invention provides the following technical scheme:
in a first aspect, a method for real-time detection and update of a static resource version includes the following steps:
step A1: acquiring all static resource files, and processing all the static resource files to obtain a text file of the version number of the static resource;
step A2: when a page is initialized, loading a stored static resource version number file from a server;
step A3: judging whether the page is in an active state;
if the page is not in an active state, no operation is performed;
if the page is in an active state, acquiring a static resource version number file and extracting a version number in the static resource version number file;
step A4: comparing the version number with the static resource version number in the static resource version number text file to judge whether the version number is consistent with the static resource version number;
if the static resource files are consistent, judging that the static resource files are not changed, and returning to execute the step A3;
if the static resource files are inconsistent, judging that the static resource files are updated, and prompting the user to refresh the page through a resident displayed notification bar.
In the above method for detecting and updating the static resource version in real time, the specific steps of processing all the static resource files in step a1 to obtain the text file of the static resource version number are as follows:
step B1: running a summary algorithm on all static resource files to obtain all static resource version numbers;
step B2: arranging all the static resource version numbers according to the name sequence of the static resource files to obtain a static resource version number text;
step B3: and operating an abstract algorithm on the static resource version number text to obtain a static resource version number text file.
The method for detecting and updating the static resource version in real time is described above, wherein the digest algorithm is SHA256 digest algorithm.
In the above method for detecting and updating the static resource version in real time, step a2 stores the obtained static resource version number file in the browser.
In the above method for detecting and updating the static resource version in real time, the step a3 of determining whether the page is in the active state is triggered and determined according to a set timer;
the steps of judging whether the page is in an active state are as follows:
step C1: the initial state of the page is an active state, the mouse and the keyboard are monitored, and time data of each operation of the mouse and the keyboard are recorded;
step C2: setting a timer, and judging whether the interval between the last time mouse and keyboard operation time data and the current time data of a user is smaller than a specified time threshold value when the timer reaches time;
if the page number is less than the preset value, the page is in an active state;
and if not, the page is in an inactive state.
In a second aspect, a system for real-time detection and update of a static resource version comprises a construction module, a state detection module, a comparison module and a prompt module;
the building module is used for acquiring all static resource files and processing all the static resource files to obtain a text file of the version number of the static resource; the static resource version number file is also used for loading the stored static resource version number file from the server when the page is initialized;
the state detection module is used for detecting the active state of the page in real time, and when the page is in the active state, the version number in the static resource version number file is extracted and transmitted to the comparison module;
the comparison module is used for obtaining the version number of the static resource in the text file of the static resource version number and the version number, comparing and judging whether the static resource version number and the version number are consistent, if so, re-detecting the active state of the page, and if not, generating prompt information transmitted to the prompt module;
the prompt module is used for displaying the prompt information on a page;
the system for detecting and updating the static resource version in real time is characterized in that a generating unit, a calculating unit and a network request unit are arranged in the building module;
the generating unit is used for acquiring a static resource file;
the computing unit is used for computing according to the obtained static resource file to obtain a text file of the version number of the static resource;
the network request unit is used for requesting to acquire a static resource version number file from a server when a page is initialized.
In the system for detecting and updating the static resource version in real time, the computing unit operates the abstract algorithm on the static resource file to obtain the static resource version number, arranges all the static resource version numbers according to the name sequence of the static resource file to obtain the static resource version number text, and operates the abstract algorithm on the static resource version number text to obtain the static resource version number text file.
In a third aspect, a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, which computer program, when executed by a processor, performs the steps of the method of any of the first aspects.
The technical scheme provided by the method and the system for detecting and updating the static resource version in real time has the following technical effects:
the method comprises the steps of generating a static resource version number text file for a static resource file in a construction period, detecting the version of the static resource version number in the static resource file of a server at regular time and comparing the version with the loaded version number of a current page in a running period if the page is active, and prompting a user to refresh the page if the version is inconsistent.
Drawings
FIG. 1 is a flow chart of a method for real-time detection and update of a static resource version according to the present invention;
FIG. 2 is a schematic diagram of an implementation of actively detecting static resource versions according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an implementation of detecting an active state of a page in an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of a system for real-time detection and update of static resource versions according to the present invention.
Wherein the reference numbers are as follows:
the device comprises a building module 100, a state detection module 200, a comparison module 300 and a prompt module 400.
Detailed Description
In order to make the technical means, the inventive features, the objectives and the effects of the invention easily understood and appreciated, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the specific drawings, and it is obvious that the described embodiments are a part of the embodiments of the present invention, but not all of the embodiments.
All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
It should be understood that the structures, ratios, sizes, and the like shown in the drawings and described in the specification are only used for matching with the disclosure of the specification, so as to be understood and read by those skilled in the art, and are not used to limit the conditions under which the present invention can be implemented, so that the present invention has no technical significance, and any structural modification, ratio relationship change, or size adjustment should still fall within the scope of the present invention without affecting the efficacy and the achievable purpose of the present invention.
In addition, the terms "upper", "lower", "left", "right", "middle" and "one" used in the present specification are for clarity of description, and are not intended to limit the scope of the present invention, and the relative relationship between the terms and the terms is not to be construed as a scope of the present invention.
The first embodiment of the invention provides a method for detecting and updating a static resource version in real time, the second embodiment is a system for detecting and updating the static resource version in real time, and the method is used for generating a text file of the static resource version number for the static resource file in a construction period, detecting the version of the static resource version number in the static resource file of a server at regular time if a page is active in a running period, comparing the version with the loaded version number of the current page, and prompting a user to refresh the page if the versions are not consistent.
As shown in fig. 1-3, in a first aspect, a method for detecting and updating a static resource version in real time includes the following steps:
step A1: at the end of a construction link, firstly, a construction script is operated to generate static resources, all static resource files are obtained after all static resource files are generated, and all static resource files are processed to obtain static resource version number text files;
step A2: when a page is initialized, loading a stored static resource version number file from a server through a network request;
step A3: judging whether the page is in an active state;
if the page is not in an active state, no operation is performed;
if the page is in an active state, acquiring a static resource version number file and extracting a version number in the static resource version number file;
step A4: comparing the version number with the static resource version number in the static resource version number text file to judge whether the version number is consistent with the static resource version number;
if the static resource files are consistent, judging that the static resource files are not changed, and returning to execute the step A3;
if the static resource files are inconsistent, judging that the static resource files are updated, and prompting a user to refresh the page through a resident displayed notification bar;
the application of the web end largely uses an http cache mechanism, and the cache strategy is divided into two types: the method comprises the steps of negotiating cache and strong cache, wherein when resources are requested each time, the negotiated cache compares a cache version with a server version, so that the burden of a server is increased undoubtedly, the server needs to spend a large amount of calculation power and time for comparing version numbers of static resources, therefore, a main stream strategy sets the strong cache for the resources in order to avoid increasing the burden of the server, the strong cache maintains an expiration time locally, and when the resources are requested each time, the local cache can be used forcibly regardless of whether the resources of the server are updated or not as long as the current time is less than the expiration time; if the static resource of the server is updated during the period that the user uses the page, the page still loads the old resource, thereby causing display error, data error and the like, and even causing system crash under severe conditions, in order to avoid the problem, the technical scheme provides a method for comparing the version number of the static resource, the version number of the static resource is generated during the construction period, the static resource file is written in, the static resource file is deployed along with the static resource file, when the user accesses the page, the front end code logic reads the text file of the static resource version number under the directory of the static resource file of the server through ajax request, the version number of the static resource of the currently loaded resource is obtained, then in the operation process, if the user is in an active state, the version number in the file of the latest static resource version number is read at regular time, the latest version number is obtained, and the latest version number is compared with the initial version number (the version number of the static resource), if the version numbers are consistent, the content of the static resource file is not changed; if the version numbers are not consistent, the content of the static resource file is changed, a notification bar which is resident and displayed at the top of the page is popped up to prompt a user to refresh, and after refreshing, the process is repeated until the content of the resource is changed again, or the user closes the browser.
The method for detecting and updating the static resource version in real time mainly aims to ensure that a user is prompted to refresh a page only when the content of the static resource file is really updated, so that unnecessary user operation and network requests are avoided, the version number can accurately reflect the content of the static resource file, and the resource and the version number are unchanged; resource change, version package must change.
In the above method for detecting and updating the static resource version in real time, the specific steps of processing all the static resource files in step a1 to obtain the text file of the static resource version number are as follows:
step B1: running a summary algorithm on all static resource files to obtain all static resource version numbers;
step B2: arranging all the static resource version numbers according to the name sequence of the static resource files to obtain a static resource version number text;
step B3: running an abstract algorithm on the static resource version number text to obtain a static resource version number text file;
because the content of the text file with the static resource version number is generated by arranging the static resource version numbers of all the static resource files in sequence, the static resource version number can accurately reflect the change of any file, and if the content and the file names of all the static resource files are not changed, the calculated integral static resource version number can not be changed;
the method comprises the steps of generating a static resource version number text file by taking the integral static resource version number as a version number, copying the static resource version number text file to a static resource file directory, distributing and deploying the static resource version number text file along with the static resource file, ensuring that the life cycles of the static resource version number text file and the static resource file are consistent, accurately recording the version of the static resource file, acquiring the static resource and deploying, and then entering an operation link;
as shown in fig. 2-3, all are applied in a web front-end browser.
The abstract algorithm is a calculation method for calculating information and converting input with any length into output with fixed length.
The above method for real-time detection and update of a static resource version, wherein the digest algorithm is SHA256 digest algorithm, the digest algorithm has collision resistance, different encryption algorithms have different collision resistance, although the collision probability is lower, in order to avoid the situation that the update is not timely caused by collision, and considering that the method has lower running frequency, more time is used for comparison, therefore, in the selection of the specific digest algorithm, the technical scheme selects no algorithm with simple calculation and poor collision resistance, such as md5 and SHA1, but selects SHA256 which is a digest algorithm with better collision resistance;
for a single file, the abstract algorithm can reflect the characteristics of the content of the file, but the static resource file usually appears in a directory form and comprises a plurality of files, so after the static resource version number of the single file is obtained, the technical scheme also combines the static resource version numbers of all the files together through a certain file name alphabetical sequence, and operates the abstract algorithm for the second time to obtain the whole static resource version number, wherein the SHA256 abstract algorithm is also selected, so that the obtained static resource version number can accurately reflect the change of the static resource, and if the content of the static resource is not changed, the finally output static resource version number is consistent no matter how many times the static resource version number is repeatedly constructed; similarly, even if only one file is added at the end by one line, the static resource version numbers are greatly different;
the final output of the technical scheme is the static resource version number in a plain text form, and repeated calculation is not needed in the subsequent process, so that the transmission and the use are convenient.
In the above method for detecting and updating the static resource version in real time, step a2 stores the obtained static resource version number file in the browser.
In the above method for detecting and updating the static resource version in real time, the step a3 of determining whether the page is in the active state is triggered and determined according to a set timer;
the steps of judging whether the page is in an active state are as follows:
step C1: the initial state of the page is an active state, the mouse and the keyboard are monitored, and time data of each operation of the mouse and the keyboard are recorded;
step C2: setting a timer, and judging whether the interval between the last time mouse and keyboard operation time data and the current time data of a user is smaller than a specified time threshold value when the timer reaches time;
if the page number is less than the preset value, the page is in an active state;
if not, the page is in an inactive state;
in the running process of the page, the static resource version number file in the server is read regularly, if the page is not in a using state, the change of the static resource file has no influence on a user, the static resource version number file does not need to be read regularly, a request causes certain performance waste to the server at the moment, and unnecessary bandwidth is consumed; the technical scheme can judge the active state of the page during the running of the page, monitors the mouse and keyboard operation of a user by setting a monitor, records the current time data when the mouse and keyboard operation is moved, clicked and rolled left/right, or pressed, can cause unnecessary consumption to the system performance because the triggering frequency of the mouse and keyboard operation is high and can reach dozens or even hundreds of times in one second, and all records cause unnecessary consumption to the system performance, so the monitor logic is optimized in a throttling mode, the current time is compared with the last triggering time when the current time is triggered every time, if the time is less than 500ms, the recording is not carried out, the triggering time can be ensured not to be recorded too frequently, and the meaningless performance consumption is avoided, in addition, the last operation time of the user is detected by a timer in a timed mode during the running of the page, if the interval between the operation time and the current time is more than a certain specified time threshold value, the user is considered to be in an inactive state, otherwise, the user is considered to be in an active state.
After the specified time, triggering an active state detection timer, and executing timer logic: judging whether the interval from the last time of triggering the mouse and the keyboard to the current time is more than 10 minutes, if so, considering that the user is not active, setting the page state as inactive, if not, considering that the user is active, setting the page state as active, resetting an active state detection timer, and waiting for the next triggering;
after the designated time, the version comparison timer triggers, and the execution timer logic: judging whether the current page is in an active state, wherein a version comparison timer and an active state detection timer run independently without mutual interference, and a single thread mechanism of a front-end JavaScript engine ensures that the problem of thread insecurity does not occur between the two timers, and the active state is judged by the steps that a static resource version is not detected at regular time for the page in the inactive state, so that unnecessary network requests are reduced, the load of a server is reduced, the timer is reset, next trigger is waited, if the current page is in the active state, a static resource version number file is obtained and stored from the server through the network request, the latest static resource version number is read, and if the latest static resource version number is consistent with the initial version number, the static resource version number of the server is not updated from the initial access page of a user to the present; on the contrary, if the latest version number is not consistent with the initial version number, the static resource of the server is considered to be updated, and the content is really different, the version number generation mechanism ensures that if the content of the static resource is not changed, the version number can be kept consistent even if the static resource is repeatedly constructed and deployed, and the static resource cannot be considered to be updated;
if the static resource is updated, popping up a resident display notification bar at the top of the page, prompting a user to ' detect the update of the static resource, and please refresh the page ' in order to avoid data errors ', wherein the notification bar is provided with a button, the user removes a current active state detection timer after clicking, the life cycle of the page is terminated, the current page is refreshed, and the operation flow is restarted;
and if the static resources are not updated, resetting the version comparison timer, and waiting for the next trigger until the page is refreshed or closed.
As shown in fig. 4, in a second aspect, a system for real-time detection and update of a static resource version includes a construction module 100, a status detection module 200, a comparison module 300, and a prompt module 400;
the building module 100 is configured to obtain all static resource files, and process all static resource files to obtain a text file of a static resource version number; the static resource version number file is also used for loading the stored static resource version number file from the server when the page is initialized;
the state detection module 200 is configured to detect an active state of a page in real time, and when the page is in the active state, extract a version number in the static resource version number file and transmit the version number to the comparison module 300;
the comparison module 300 uses the version number to obtain the static resource version number and the version number in the static resource version number text file, compares and judges whether the static resource version number and the version number are consistent, if so, redetects the active state of the page, and if not, generates the prompt information transmitted to the prompt module 400;
the prompt module 400 is used for displaying prompt information on a page;
in the system for detecting and updating the static resource version in real time, the building module 100 is internally provided with a generating unit, a calculating unit and a network requesting unit;
the generating unit is used for acquiring the static resource file;
the calculation unit is used for calculating according to the acquired static resource file to obtain a text file of the version number of the static resource;
the network request unit is used for requesting to acquire the static resource version number file from the server when the page is initialized.
In the system for real-time detection and update of the static resource version, the computing unit operates the abstract algorithm on the static resource file to obtain the static resource version number, arranges all the static resource version numbers according to the name sequence of the static resource file to obtain the static resource version number text, and operates the abstract algorithm on the static resource version number text to obtain the static resource version number text file.
In a third aspect, a computer-readable storage medium has stored thereon a computer program which, when executed by a processor, performs the steps of the method of any one of the first aspect.
For example, the memory may include random access memory, flash memory, read only memory, programmable read only memory, non-volatile memory or registers, or the like;
the processor may be a Central Processing Unit (CPU) or the like, or a Graphics Processing Unit (GPU) memory may store executable instructions;
the processor may execute execution instructions stored in the memory to implement the various processes described herein.
It will be appreciated that the memory in this embodiment can be either volatile memory or nonvolatile memory, or can include both volatile and nonvolatile memory;
the non-volatile memory may be a ROM (Read-only memory), a PROM (programmable Read-only memory), an EPROM (erasable programmable Read-only memory), an EEPROM (electrically erasable programmable Read-only memory), or a flash memory.
The volatile memory may be a RAM (random access memory) which functions as an external cache;
by way of illustration and not limitation, many forms of RAM are available, such as SRAM (staticaram, static random access memory), DRAM (dynamic RAM, dynamic random access memory), SDRAM (synchronous DRAM ), DDRSDRAM (double data rate SDRAM, double data rate synchronous DRAM), ESDRAM (Enhanced SDRAM, Enhanced synchronous DRAM), SLDRAM (synchlink DRAM, synchronous link DRAM), and DRRAM (directrrambus RAM, direct memory random access memory). The memory described herein is intended to comprise, without being limited to, these and any other suitable types of memory.
In some embodiments, the memory stores elements, upgrade packages, executable units, or data structures, or a subset thereof, or an extended set thereof: operating systems and applications;
the operating system includes various system programs, such as a framework layer, a core library layer, a driver layer, and the like, and is used for implementing various basic services and processing hardware-based tasks;
the application programs comprise various application programs and are used for realizing various application services. The program for implementing the method of the embodiment of the present invention may be included in the application program.
Those of skill in the art would understand that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of software and electronic hardware;
whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution;
skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments of the present application, the disclosed system, apparatus and method may be implemented in other ways;
for example, the division of a unit or a module is only one logic function division, and there may be another division manner in actual implementation;
for example, a plurality of units or modules or components may be combined or may be integrated into another system;
in addition, functional units or modules in the embodiments of the present application may be integrated into one processing unit or module, or may exist separately and physically.
It should be understood that, in the various embodiments of the present application, the sequence numbers of the processes do not mean the execution sequence, and the execution sequence of the processes should be determined by the functions and the inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a machine-readable storage medium;
therefore, the technical solution of the present application may be embodied in the form of a software product, which may be stored in a machine-readable storage medium and may include several instructions to cause an electronic device to execute all or part of the processes of the technical solution described in the embodiments of the present application;
the storage medium may include various media that can store program codes, such as ROM, RAM, a removable disk, a hard disk, a magnetic disk, or an optical disk.
In summary, the method and system for real-time detection and update of the static resource version of the present invention can generate a text file of the static resource version number for the static resource file in the construction period, and in the operation period, if the page is active, the version of the static resource version number in the static resource file of the server is detected at regular time, and compared with the loaded version number of the current page, if the version is inconsistent, the user is prompted to refresh the page.
Specific embodiments of the invention have been described above. It is to be understood that the invention is not limited to the particular embodiments described above, in that devices and structures not described in detail are understood to be implemented in a manner common in the art; various changes or modifications may be made by one skilled in the art within the scope of the claims without departing from the spirit of the invention, and without affecting the spirit of the invention.

Claims (9)

1. A method for real-time detection and update of static resource versions is characterized by comprising the following steps:
step A1: acquiring all static resource files, and processing all the static resource files to obtain a text file of the version number of the static resource;
step A2: when a page is initialized, loading a stored static resource version number file from a server;
step A3: judging whether the page is in an active state;
if the page is not in an active state, no operation is performed;
if the page is in an active state, acquiring a static resource version number file and extracting a version number in the static resource version number file;
step A4: comparing the version number with the static resource version number in the static resource version number text file to judge whether the version number is consistent with the static resource version number;
if the static resource files are consistent, judging that the static resource files are not changed, and returning to execute the step A3;
if the static resource files are inconsistent, judging that the static resource files are updated, and prompting the user to refresh the page through a resident displayed notification bar.
2. The method for detecting and updating the version of the static resource according to claim 1, wherein the specific steps of processing all the static resource files in the step a1 to obtain the text file of the version number of the static resource are as follows:
step B1: running a summary algorithm on all static resource files to obtain all static resource version numbers;
step B2: arranging all the static resource version numbers according to the name sequence of the static resource files to obtain a static resource version number text;
step B3: and operating an abstract algorithm on the static resource version number text to obtain a static resource version number text file.
3. The method as claimed in claim 2, wherein the summarization algorithm is SHA256 summarization algorithm.
4. The method as claimed in claim 3, wherein the step A2 is executed by saving the static resource version number file obtained in step A2 to the browser.
5. The method for real-time detecting and updating of static resource version as claimed in claim 4, wherein the step of determining whether the page is in the active state in step a3 is triggered by setting a timer to determine whether the page is in the active state;
the steps of judging whether the page is in an active state are as follows:
step C1: the initial state of the page is an active state, the mouse and the keyboard are monitored, and time data of each operation of the mouse and the keyboard are recorded;
step C2: setting a timer, and judging whether the interval between the last time mouse and keyboard operation time data and the current time data of a user is smaller than a specified time threshold value when the timer reaches time;
if the page number is less than the preset value, the page is in an active state;
and if not, the page is in an inactive state.
6. A system for detecting and updating a static resource version in real time is characterized by comprising a construction module, a state detection module, a comparison module and a prompt module;
the building module is used for acquiring all static resource files and processing all the static resource files to obtain a text file of the version number of the static resource; the static resource version number file is also used for loading the stored static resource version number file from the server when the page is initialized;
the state detection module is used for detecting the active state of the page in real time, and when the page is in the active state, the version number in the static resource version number file is extracted and transmitted to the comparison module;
the comparison module is used for obtaining the version number of the static resource in the text file of the static resource version number and the version number, comparing and judging whether the static resource version number and the version number are consistent, if so, re-detecting the active state of the page, and if not, generating prompt information transmitted to the prompt module;
the prompt module is used for displaying the prompt information on a page.
7. The system for real-time detection and update of static resource version of claim 6, wherein the building module is built-in with a generating unit, a calculating unit, a network requesting unit;
the generating unit is used for acquiring a static resource file;
the computing unit is used for computing according to the obtained static resource file to obtain a text file of the version number of the static resource;
the network request unit is used for requesting to acquire a static resource version number file from a server when a page is initialized.
8. The system according to claim 7, wherein the computing unit performs an abstract algorithm on the static resource file to obtain the static resource version number, arranges all the static resource version numbers according to the name sequence of the static resource file to obtain a static resource version number text, and performs an abstract algorithm on the static resource version number text to obtain the static resource version number text file.
9. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, which computer program, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 5.
CN202110988918.1A 2021-08-26 2021-08-26 Method and system for real-time detection and update of static resource version Active CN113703807B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110988918.1A CN113703807B (en) 2021-08-26 2021-08-26 Method and system for real-time detection and update of static resource version

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110988918.1A CN113703807B (en) 2021-08-26 2021-08-26 Method and system for real-time detection and update of static resource version

Publications (2)

Publication Number Publication Date
CN113703807A true CN113703807A (en) 2021-11-26
CN113703807B CN113703807B (en) 2023-12-15

Family

ID=78655271

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110988918.1A Active CN113703807B (en) 2021-08-26 2021-08-26 Method and system for real-time detection and update of static resource version

Country Status (1)

Country Link
CN (1) CN113703807B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114518922A (en) * 2021-12-28 2022-05-20 百果园技术(新加坡)有限公司 Page display system, method and device, electronic equipment and storage medium
CN114924740A (en) * 2022-04-26 2022-08-19 江苏康众汽配有限公司 Active detection method for resource failure in front-end single-page application

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103092665A (en) * 2013-03-01 2013-05-08 畅捷通信息技术股份有限公司 Immediate updating device and immediate updating method
US20130311599A1 (en) * 2012-05-17 2013-11-21 International Business Machines Corporation Updating Web Resources
CN106649395A (en) * 2015-11-03 2017-05-10 腾讯科技(深圳)有限公司 Webpage updating method and apparatus
CN107301051A (en) * 2017-06-27 2017-10-27 深圳市金立通信设备有限公司 The caching of terminal dynamic data and exchange method, terminal, system and computer-readable recording medium
CN108304207A (en) * 2018-03-01 2018-07-20 上海找钢网信息科技股份有限公司 Mix the resource regeneration method and system of APP application programs
US20190227780A1 (en) * 2018-01-24 2019-07-25 Citrix Systems, Inc. Systems and methods for versioning a cloud environment for a device
CN110244957A (en) * 2019-05-10 2019-09-17 阿里巴巴集团控股有限公司 A kind of resource data updating method, apparatus and system
CN110244962A (en) * 2019-04-29 2019-09-17 北京辰森世纪科技股份有限公司 Load application file and device, system, storage medium, electronic device
CN110244975A (en) * 2018-03-08 2019-09-17 北京京东尚科信息技术有限公司 A kind of generation method and device of static resource version number
WO2019242166A1 (en) * 2018-06-22 2019-12-26 平安科技(深圳)有限公司 Application update method and system, and computer device and storage medium
CN111046311A (en) * 2019-12-17 2020-04-21 深圳前海环融联易信息科技服务有限公司 Method and device for realizing traceless iteration version of PC (personal computer) end, computer equipment and storage medium
CN113268239A (en) * 2021-06-04 2021-08-17 平安科技(深圳)有限公司 Desktop application view construction method, device, equipment and storage medium

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130311599A1 (en) * 2012-05-17 2013-11-21 International Business Machines Corporation Updating Web Resources
CN103092665A (en) * 2013-03-01 2013-05-08 畅捷通信息技术股份有限公司 Immediate updating device and immediate updating method
CN106649395A (en) * 2015-11-03 2017-05-10 腾讯科技(深圳)有限公司 Webpage updating method and apparatus
CN107301051A (en) * 2017-06-27 2017-10-27 深圳市金立通信设备有限公司 The caching of terminal dynamic data and exchange method, terminal, system and computer-readable recording medium
US20190227780A1 (en) * 2018-01-24 2019-07-25 Citrix Systems, Inc. Systems and methods for versioning a cloud environment for a device
CN108304207A (en) * 2018-03-01 2018-07-20 上海找钢网信息科技股份有限公司 Mix the resource regeneration method and system of APP application programs
CN110244975A (en) * 2018-03-08 2019-09-17 北京京东尚科信息技术有限公司 A kind of generation method and device of static resource version number
WO2019242166A1 (en) * 2018-06-22 2019-12-26 平安科技(深圳)有限公司 Application update method and system, and computer device and storage medium
CN110244962A (en) * 2019-04-29 2019-09-17 北京辰森世纪科技股份有限公司 Load application file and device, system, storage medium, electronic device
CN110244957A (en) * 2019-05-10 2019-09-17 阿里巴巴集团控股有限公司 A kind of resource data updating method, apparatus and system
CN111046311A (en) * 2019-12-17 2020-04-21 深圳前海环融联易信息科技服务有限公司 Method and device for realizing traceless iteration version of PC (personal computer) end, computer equipment and storage medium
CN113268239A (en) * 2021-06-04 2021-08-17 平安科技(深圳)有限公司 Desktop application view construction method, device, equipment and storage medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
DEEPAK KUMAR GANESHIYA等: "A novel approach for webpage ranking using updated content", 《014 5TH INTERNATIONAL CONFERENCE - CONFLUENCE THE NEXT GENERATION INFORMATION TECHNOLOGY SUMMIT (CONFLUENCE)》, pages 210 - 214 *
张健: "Web资源离线化和增量更新平台的设计与实现", 《中国优秀硕士学位论文全文数据库 信息科技辑》, no. 1, pages 138 - 800 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114518922A (en) * 2021-12-28 2022-05-20 百果园技术(新加坡)有限公司 Page display system, method and device, electronic equipment and storage medium
CN114518922B (en) * 2021-12-28 2024-03-05 百果园技术(新加坡)有限公司 Page display system, method and device, electronic equipment and storage medium
CN114924740A (en) * 2022-04-26 2022-08-19 江苏康众汽配有限公司 Active detection method for resource failure in front-end single-page application

Also Published As

Publication number Publication date
CN113703807B (en) 2023-12-15

Similar Documents

Publication Publication Date Title
US9436572B2 (en) Method and system to detect a cached web page
US8418139B2 (en) System and method for updating initialization parameters for application software from within a software development environment
CN113703807B (en) Method and system for real-time detection and update of static resource version
US10613970B1 (en) Method and system for managing deployment of software application components based on software performance data
US8978028B2 (en) Transactional multi-package installation
US11018965B1 (en) Serverless function scaling
CN111078659B (en) Model updating method, device, computer readable storage medium and computer equipment
US10362089B1 (en) Methods and systems for dynamically generating and reusing dynamic web content
WO2020034951A1 (en) Front-end programming language-based method for optimizing image lazy-loading, and electronic apparatus
WO2016150324A1 (en) Page module rendering method, apparatus and display device
US9690633B2 (en) Synchronization method
CN112182442A (en) Page processing method and device, electronic equipment and computer readable storage medium
Okamura et al. Comprehensive evaluation of aperiodic checkpointing and rejuvenation schemes in operational software system
US8860735B2 (en) Aligning script animations with display refresh
US20130067320A1 (en) Batch Document Formatting and Layout on Display Refresh
CN110990132A (en) Asynchronous task processing method and device, computer equipment and storage medium
US20100318987A1 (en) Bootstrapping streamed and virtualized applications
CN116821533A (en) Page rendering method, computer device and computer-readable storage medium
US10558528B2 (en) Reconstruction of system definitional and state information
CN108062224B (en) Data reading and writing method and device based on file handle and computing equipment
CN111427623A (en) Program exit method, device, computer equipment and storage medium
CN111078257A (en) Loading method and related device of H5 application package
US20240036971A1 (en) Proactive integrity checks
CN116304458B (en) Method, device, equipment and medium for web page real-time notification update
CN110968365B (en) Loading method and device

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
GR01 Patent grant
GR01 Patent grant