CN106293746B - Method and system for updating browser script - Google Patents

Method and system for updating browser script Download PDF

Info

Publication number
CN106293746B
CN106293746B CN201610659949.1A CN201610659949A CN106293746B CN 106293746 B CN106293746 B CN 106293746B CN 201610659949 A CN201610659949 A CN 201610659949A CN 106293746 B CN106293746 B CN 106293746B
Authority
CN
China
Prior art keywords
script
local storage
browser
address
content
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.)
Active
Application number
CN201610659949.1A
Other languages
Chinese (zh)
Other versions
CN106293746A (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.)
Fujian TQ Digital Co Ltd
Original Assignee
Fujian TQ Digital 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 Fujian TQ Digital Co Ltd filed Critical Fujian TQ Digital Co Ltd
Priority to CN201610659949.1A priority Critical patent/CN106293746B/en
Publication of CN106293746A publication Critical patent/CN106293746A/en
Application granted granted Critical
Publication of CN106293746B publication Critical patent/CN106293746B/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
    • G06F8/658Incremental updates; Differential updates

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 Transfer Between Computers (AREA)

Abstract

The invention provides an browser script updating method and a system, the method comprises the steps that a browser acquires scripts in an Ajax request mode, the scripts are dynamically executed one by one in a dynamic interpretation mode according to the sequence of the Ajax request, hashes of addresses, version numbers, contents and contents of the executed scripts are stored in a local storage with the addresses as indexes, when the browser requests to acquire the scripts, if the addresses of the requested scripts are the same as the addresses of the scripts in the local storage and the version numbers of the requested scripts are larger than the version numbers of the scripts in the local storage, an increment package of the scripts is acquired from a server according to the addresses, the version numbers and the hashes of the contents of the requested scripts, the increment package and the contents of the scripts in the local storage are combined to complete updating of the browser scripts, the scripts can be updated in an increment updating mode, the whole scripts do not need to be downloaded again, and flow and bandwidth are saved.

Description

Method and system for updating browser script
Technical Field
The invention relates to the technical field of computers, in particular to an browser script updating method and system.
Background
At present, the script cache of the browser usually adopts script tags to mark scripts to be loaded, and the browser loads the scripts according to script addresses in the tags. And the script update needs to download the whole script file of the new version for updating.
For example, chinese patent publication No. CN 103823694 a provides an update method for script files, which parses the latest script file into a syntax tree in real time when it is detected that the script file is modified or updated, and stores the parsed syntax tree in a syntax tree buffer, so as to complete real-time update of the script file, and the browser can also be applied to the syntax tree corresponding to the latest script file in real time.
The method improves the real-time browsing efficiency of the user, thereby enhancing the user experience. However, the syntax tree of the whole script file is cached, so that the bandwidth occupied during downloading is large, and the flow is very wasted.
Disclosure of Invention
The invention aims to solve the technical problem of providing browser scripts updating method and system, which can reduce the occupied bandwidth when the scripts are updated and improve the updating speed.
In order to solve the technical problems, the invention adopts the technical scheme that:
A method for updating browser script, comprising:
the browser acquires the script in an Ajax request mode;
dynamically executing the scripts one by one in a dynamic interpretation mode according to the sequence of the Ajax requests;
storing the address, the version number, the content and the hash of the content of the executed script into a local storage by taking the address as an index;
when a browser requests to acquire a script, if the address of the requested script is the same as the address of the script in a local storage and the version number of the requested script is greater than the version number of the script in the local storage, acquiring an incremental package of the script from a server according to the address, the version number and the hash of contents of the requested script;
and merging the increment package and the script content in the local storage to finish the updating of the browser script.
The other technical schemes provided by the invention are as follows:
A browser script updating system, comprising:
the script obtaining module is used for obtaining a script by the browser in an Ajax request mode;
the execution module is used for dynamically executing the scripts one by one in a dynamic interpretation mode according to the sequence of the Ajax request;
the storage module is used for storing the address, the version number, the content and the hash of the content of the executed script into a local storage by taking the address as an index;
the system comprises an incremental package acquisition module, a server and a storage module, wherein the incremental package acquisition module is used for acquiring an incremental package of a script from the server according to the address and the version number of the requested script and the hash of content of the requested script if the address of the requested script is the same as the address of the script in the local storage and the version number of the requested script is greater than the version number of the script in the local storage when the browser requests to acquire the script;
and the updating module is used for combining the increment package with the content of the script in the local storage to finish the updating of the browser script.
The invention has the beneficial effects that: the method obtains the script in the Ajax request mode, can store the script to the local, judges whether the needed script exists in the local storage or not when the script is required to be obtained each time, updates the script in an incremental updating mode when the needed script exists in the local storage and the version is lower than the required version, and is different from the method that the script to be loaded is marked by a < script > label in the prior art and the script is loaded by the browser according to the script address in the label.
Drawings
FIG. 1 is a flowchart of a method for updating browser scripts according to an embodiment of the present invention;
FIG. 2 is a schematic structural diagram of a system for updating browser scripts according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a system for updating browser scripts according to a second embodiment of the present invention.
Description of reference numerals:
1. the device comprises a script acquisition module, a script execution module, a storage module, an increment package acquisition module, a module 41, a acquisition module, a module 42, a calculation module, a module 5, an update module, a module 51 and a second calculation module.
Detailed Description
In order to explain technical contents, achieved objects, and effects of the present invention in detail, the following description is made with reference to the accompanying drawings in combination with the embodiments.
The most key concept of the invention is as follows: and acquiring the script in an Ajax request mode, and updating the script in an incremental updating mode.
The technical terms related to the invention are explained as follows:
Figure BDA0001077037060000031
referring to fig. 1, the present invention provides:
A method for updating browser script, comprising:
the browser acquires the script in an Ajax request mode;
dynamically executing the scripts one by one in a dynamic interpretation mode according to the sequence of the Ajax requests;
storing the address, the version number, the content and the hash of the content of the executed script into a local storage by taking the address as an index;
when a browser requests to acquire a script, if the address of the requested script is the same as the address of the script in a local storage and the version number of the requested script is greater than the version number of the script in the local storage, acquiring an incremental package of the script from a server according to the address, the version number and the hash of contents of the requested script;
and merging the increment package and the script content in the local storage to finish the updating of the browser script.
From the above description, the method for updating browser scripts of the present invention has the following beneficial effects: the script is obtained in the Ajax request mode, and the script in the local storage is updated in the incremental updating mode, so that the bandwidth resource is saved.
, obtaining the delta package of the script from the server according to the address, the version number and the hash of the content of the requested script, comprising:
the server acquires a script corresponding to the hash of the content according to the address of the script in the request;
the server processes the script in the local storage and the script corresponding to the obtained hash of the content through a delta algorithm to generate an increment package;
and the server sends the increment package to a browser.
From the above description, the server obtains the latest version of the script according to the request sent by the browser, calculates the script and the script in the local storage to generate the incremental package, and sends the incremental package to the browser.
, merging the delta package with the content of the script in the local storage to complete the updating of the browser script, including:
and the browser combines the increment package and the script in the local storage through a delta algorithm to generate a script file with the latest version.
As can be seen from the above description, since the browser acquires the delta package from the server, the delta package and the local script need to be calculated to generate the latest version of the script file. Different algorithms can be selected for specific calculation, so long as the calculation of the server and the browser corresponds.
Further , when the browser requests to obtain the script, if there is a script in the local storage that has the same address as the requested script and the version number of the requested script is less than or equal to the version number of the script in the local storage, then the script in the local storage is obtained.
As can be seen from the above description, the address of the script requested by the browser already exists in the local storage, and the version number is the same, which indicates that the requested script does not need to be updated, and the requested script can be directly obtained from the local storage without downloading.
, dynamically executing the scripts one by one in a dynamic analysis mode according to the sequence of Ajax requests, storing the address, version number, content and hash of the content of the executed script in a local storage by taking the address as an index, comprising:
calling an eval function to dynamically interpret the script;
if the script is correctly executed, storing the script in a local storage;
and if the script is abnormal, encoding the script by adopting a base64 algorithm and storing the encoded script in a local storage.
From the above description, the script execution mode is to dynamically interpret the script through the eval function, and other methods capable of achieving the same effect may be adopted, where the script that is successfully executed is directly stored locally, and the script that is failed to be executed is encoded and then stored, so as to reduce the data size.
Referring to fig. 2, another technical solutions of the present invention are:
A browser script updating system, comprising:
the script obtaining module 1 is used for obtaining a script by a browser in an Ajax request mode;
the execution module 2 is used for dynamically executing the scripts one by one in a dynamic interpretation mode according to the sequence of the Ajax request;
the storage module 3 is used for storing the address, the version number, the content and the hash of the content of the executed script into a local storage by taking the address as an index;
the incremental package obtaining module 4 is configured to, when the browser requests to obtain the script, obtain an incremental package of the script from the server according to the address and the version number of the requested script and the hash of the content of the requested script if the address of the requested script is the same as the address of the script in the local storage and the version number of the requested script is greater than the version number of the script in the local storage;
and the updating module 5 is used for combining the increment package with the content of the script in the local storage to complete the updating of the browser script.
, the incremental package obtaining module 4 includes:
, an obtaining module 41, configured to obtain, by the server, a script corresponding to the hash of the content according to an address of the script in the request;
is a calculation module 42, which is used for the server to process the script in the local storage and the obtained script corresponding to the hash of the content by delta algorithm, and generate an increment package;
and a sending module 43, configured to send the increment package to the browser by the server.
As can be seen from the above description, the server obtains the latest version of the script corresponding to the request through the th obtaining module, calculates the incremental package through the th calculating module, and sends the incremental package to the browser through the sending module.
Further to step , the update module 5 includes:
and the second computing module 51 is configured to merge the delta package and the script in the local storage through a delta algorithm by the browser, so as to generate a script file of the latest version.
From the above description, the browser generates a new script file after calculating the incremental package and the local script through the second calculation module, and completes the update.
Further , when the browser requests to obtain the script, if there is a script in the local storage that has the same address as the requested script and the version number of the requested script is less than or equal to the version number of the script in the local storage, then the script in the local storage is obtained.
, the execution module 2 is used to call eval function to dynamically interpret the script, the storage module 3 is used to store the script in local storage if the script is executed correctly, and if the script is executed abnormally, the script is encoded by base64 algorithm and then stored in local storage.
From the above description, the present solution is not limited to the eval function, base64 algorithm, but any method that can achieve the same effect in the prior art can be used.
Example of the present invention is:
A method for updating browser script, comprising:
when a browser loads a page, a request for acquiring a script is sent to a server in an Ajax mode; and obtaining a script according to the request; the request includes an address, version number, and hash of the content of the script;
dynamically executing the scripts one by one in a dynamic interpretation mode according to the sequence of Ajax requests;
storing the address, the version number, the content and the hash of the content of the executed script into a local storage by taking the address as an index; specifically, an eval function is called to dynamically explain the script; if the script is correctly executed, storing the script in a local storage; if the script is abnormal, encoding the script by adopting a base64 algorithm and then storing the encoded script in a local storage;
when the browser requests to acquire the script, the difference between the requested script and the script in the local storage is judged firstly; if the address of the requested script is the same as the address of the script in the local storage and the version number of the requested script is greater than the version number of the script in the local storage, sending a request for acquiring the script to the server; the server acquires the script of the latest version corresponding to the hash of the content according to the address of the script in the request; the server processes the script in the local storage and the script corresponding to the obtained hash of the content through a delta algorithm to generate an increment package; the server sends the increment package to a browser;
after the browser receives the increment package, combining the increment package with the content of the script in the local storage through a delta algorithm to generate a script file of the latest version, and finishing the updating of the browser script;
and if the script in the local storage which is the same as the requested script address exists and the version number of the requested script is less than or equal to the version number of the script in the local storage, acquiring the script in the local storage.
Referring to fig. 3, the second embodiment of the present invention is:
A system corresponding to the method for updating browser script of the aforementioned embodiment , comprising:
the script obtaining module 1 is used for obtaining a script by a browser in an Ajax request mode;
the execution module 2 is used for dynamically executing the scripts one by one in a dynamic interpretation mode according to the sequence of the Ajax request;
the storage module 3 is used for storing the address, the version number, the content and the hash of the content of the executed script into a local storage by taking the address as an index; specifically, the execution module 2 is configured to call an eval function to dynamically interpret the script; the storage module 3 is configured to store the script into a local storage if the script is executed correctly; if the script is abnormal, encoding the script by adopting a base64 algorithm and then storing the encoded script in a local storage;
the system comprises an incremental packet acquisition module 4, a sending module 43, a storage module and a storage module, wherein the incremental packet acquisition module 4 is used for acquiring an incremental packet of a script from a server according to the address and the version number of the requested script and the hash of content when a browser requests to acquire the script, and the address of the requested script is the same as the address of the script in a local storage and the version number of the requested script is greater than the version number of the script in the local storage;
the updating module 5 is used for combining the increment package with the content of the script in the local storage to complete the updating of the browser script; the update module 5 includes: the second calculation module 51 is configured to merge the delta package and the script in the local storage through a delta algorithm by the browser, and generate a script file of the latest version;
when the browser requests to acquire the script, if the script in the local storage with the same address as the requested script exists and the version number of the requested script is smaller than or equal to the version number of the script in the local storage, the script in the local storage is acquired.
In summary, the method and the system for updating the browser script provided by the invention can update the script in an incremental updating manner without downloading the whole script file again, thereby saving the flow and the bandwidth.
The above description is only an embodiment of the present invention, and not intended to limit the scope of the present invention, and all equivalent changes made by using the contents of the present specification and the drawings, or applied directly or indirectly to the related technical fields, are included in the scope of the present invention.

Claims (6)

1, A method for updating browser script, comprising:
the browser acquires the script in an Ajax request mode;
dynamically executing the scripts one by one in a dynamic interpretation mode according to the sequence of the Ajax requests;
storing the address, the version number, the content and the hash of the content of the executed script into a local storage by taking the address as an index;
when a browser requests to acquire a script, if the address of the requested script is the same as the address of the script in a local storage and the version number of the requested script is greater than the version number of the script in the local storage, acquiring an incremental package of the script from a server according to the address, the version number and the hash of contents of the requested script;
merging the increment package and the script content in the local storage to complete the updating of the browser script;
obtaining the increment package of the script from the server according to the address, the version number and the hash of the content of the requested script, wherein the increment package comprises the following steps:
the server acquires a script corresponding to the hash of the content according to the address of the script in the request;
the server processes the script in the local storage and the script corresponding to the obtained hash of the content through a delta algorithm to generate an increment package;
the server sends the increment package to a browser;
when the browser requests to acquire the script, if the script in the local storage with the same address as the requested script exists and the version number of the requested script is smaller than or equal to the version number of the script in the local storage, the script in the local storage is acquired.
2. The method for updating browser script according to claim 1, wherein merging the delta package with the content of the script in the local storage to complete the updating of the browser script comprises:
and the browser combines the increment package and the script in the local storage through a delta algorithm to generate a script file with the latest version.
3. The method for updating a browser script according to claim 1, wherein the script is dynamically executed one by one in a dynamic analytic manner in the order of Ajax requests; storing the address, version number, content and hash of the content of the executed script into a local storage by taking the address as an index, wherein the storing comprises the following steps:
calling an eval function to dynamically interpret the script;
if the script is correctly executed, storing the script in a local storage;
and if the script is abnormal, encoding the script by adopting a base64 algorithm and storing the encoded script in a local storage.
4, A browser script updating system, comprising:
the script obtaining module is used for obtaining a script by the browser in an Ajax request mode;
the execution module is used for dynamically executing the scripts one by one in a dynamic interpretation mode according to the sequence of the Ajax request;
the storage module is used for storing the address, the version number, the content and the hash of the content of the executed script into a local storage by taking the address as an index;
the system comprises an incremental package acquisition module, a server and a storage module, wherein the incremental package acquisition module is used for acquiring an incremental package of a script from the server according to the address and the version number of the requested script and the hash of content of the requested script if the address of the requested script is the same as the address of the script in the local storage and the version number of the requested script is greater than the version number of the script in the local storage when the browser requests to acquire the script;
the updating module is used for combining the increment package with the content of the script in the local storage to finish updating of the browser script;
the increment package obtaining module comprises:
, an obtaining module, configured to obtain, by the server, a script corresponding to the hash of the content according to an address of the script in the request;
an calculation module, configured to process, by the server through a delta algorithm, the script in the local storage and the obtained script corresponding to the hash of the content, and generate an incremental package;
the sending module is used for sending the increment package to a browser by the server;
when the browser requests to acquire the script, if the script in the local storage with the same address as the requested script exists and the version number of the requested script is smaller than or equal to the version number of the script in the local storage, the script in the local storage is acquired.
5. The browser script updating system of claim 4, wherein the updating module comprises:
and the second calculation module is used for merging the increment package and the script in the local storage through a delta algorithm by the browser to generate a script file with the latest version.
6. The browser script updating system of claim 4, wherein the execution module is configured to invoke an eval function to dynamically interpret the script; the storage module is used for storing the script into a local storage if the script is correctly executed; and if the script is abnormal, encoding the script by adopting a base64 algorithm and storing the encoded script in a local storage.
CN201610659949.1A 2016-08-12 2016-08-12 Method and system for updating browser script Active CN106293746B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610659949.1A CN106293746B (en) 2016-08-12 2016-08-12 Method and system for updating browser script

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610659949.1A CN106293746B (en) 2016-08-12 2016-08-12 Method and system for updating browser script

Publications (2)

Publication Number Publication Date
CN106293746A CN106293746A (en) 2017-01-04
CN106293746B true CN106293746B (en) 2020-01-31

Family

ID=57669857

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610659949.1A Active CN106293746B (en) 2016-08-12 2016-08-12 Method and system for updating browser script

Country Status (1)

Country Link
CN (1) CN106293746B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107015826B (en) * 2017-03-16 2020-09-04 腾讯科技(深圳)有限公司 Script file loading method, terminal and server
CN108959455B (en) * 2018-06-15 2020-12-04 未鲲(上海)科技服务有限公司 Single-page Web application implementation method and device, computer equipment and storage medium
CN114025333A (en) * 2021-11-01 2022-02-08 中国电信股份有限公司甘肃分公司 Flow configuration method, device and storage medium

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103279373A (en) * 2013-05-31 2013-09-04 广州市动景计算机科技有限公司 Method and device for updating browser shell functions
CN103377064A (en) * 2012-04-28 2013-10-30 阿里巴巴集团控股有限公司 Page script loading method and page script loading device
CN103543991A (en) * 2012-07-09 2014-01-29 百度在线网络技术(北京)有限公司 Method for extending functions of browser and browser system
CN103823694A (en) * 2014-02-10 2014-05-28 深圳市同洲电子股份有限公司 Method and device for updating script file
CN104123149A (en) * 2013-04-28 2014-10-29 腾讯科技(深圳)有限公司 Software upgrading method, device, client and system
CN104765816A (en) * 2015-04-03 2015-07-08 北京金山安全软件有限公司 Browser upgrading method and device and electronic equipment
CN104866351A (en) * 2015-05-27 2015-08-26 百富计算机技术(深圳)有限公司 Data transmission method, server and client

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7685168B2 (en) * 2007-08-31 2010-03-23 International Business Machines Corporation Removing web application flicker using AJAX and page templates
JP4846832B2 (en) * 2009-08-07 2011-12-28 株式会社日立製作所 Web page display method, computer system, and program

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103377064A (en) * 2012-04-28 2013-10-30 阿里巴巴集团控股有限公司 Page script loading method and page script loading device
CN103543991A (en) * 2012-07-09 2014-01-29 百度在线网络技术(北京)有限公司 Method for extending functions of browser and browser system
CN104123149A (en) * 2013-04-28 2014-10-29 腾讯科技(深圳)有限公司 Software upgrading method, device, client and system
CN103279373A (en) * 2013-05-31 2013-09-04 广州市动景计算机科技有限公司 Method and device for updating browser shell functions
CN103823694A (en) * 2014-02-10 2014-05-28 深圳市同洲电子股份有限公司 Method and device for updating script file
CN104765816A (en) * 2015-04-03 2015-07-08 北京金山安全软件有限公司 Browser upgrading method and device and electronic equipment
CN104866351A (en) * 2015-05-27 2015-08-26 百富计算机技术(深圳)有限公司 Data transmission method, server and client

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
"基于Ajax的动态JavaScript文件加载模型";熊海东 等;《西昌学院学报(自然科学版)》;20110920;第25卷(第3期);第52-54页 *

Also Published As

Publication number Publication date
CN106293746A (en) 2017-01-04

Similar Documents

Publication Publication Date Title
US10931731B2 (en) Adaptive learning periods in HTML streaming
US10042948B2 (en) Identifying correlated components of dynamic content
US9178934B1 (en) Modifying web content at a client
US9075663B2 (en) Cloud-based web workers and storages
US10091289B2 (en) Provisional execution of dynamic content component
US9063765B2 (en) System and methods for distributed execution of computer executable programs utilizing asymmetric translation
US8752016B2 (en) Converting JavaScript into a device-independent representation
WO2017084555A1 (en) Method for generating and installing trusted application for use in a trusted execution environment
WO2015043428A1 (en) Method, system, browser and proxy server for loading webpage
CN106293746B (en) Method and system for updating browser script
CN109542851A (en) File updating method, apparatus and system
CN102938776A (en) Dynamic page processing system based on Asynchronous JavaScript and XML (ajax) technique
WO2018035799A1 (en) Data query method, application and database servers, middleware, and system
Pande et al. Enhanced web application and browsing performance through service-worker infusion framework
WO2015021809A1 (en) Dynamic language code execution method and apparatus
CN102946442A (en) Method and system for updating and releasing file based on smart refreshing
CN103841117A (en) JAAS login method and server based on Cookie mechanism
US10148735B1 (en) Application layer load balancer
CN102882988A (en) Method, device and equipment for acquiring address information of resource information
CN110929194A (en) Abstract algorithm-based static resource file cache control method and system
CN115757492A (en) Hotspot data processing method and device, computer equipment and storage medium
US10970354B2 (en) Method for processing code and increasing website and client interaction speed
US10129363B2 (en) Plug-in cache
CN111291083B (en) Webpage source code data processing method and device and computer equipment
CN109783499B (en) Data caching method, device and server

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant