CN114584543A - Web-based resource quick access method, system, medium and equipment - Google Patents

Web-based resource quick access method, system, medium and equipment Download PDF

Info

Publication number
CN114584543A
CN114584543A CN202210143477.XA CN202210143477A CN114584543A CN 114584543 A CN114584543 A CN 114584543A CN 202210143477 A CN202210143477 A CN 202210143477A CN 114584543 A CN114584543 A CN 114584543A
Authority
CN
China
Prior art keywords
communication data
worker
task
main thread
data
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
CN202210143477.XA
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.)
Baianju Information Technology Shanghai Co ltd
Original Assignee
Baianju Information Technology Shanghai 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 Baianju Information Technology Shanghai Co ltd filed Critical Baianju Information Technology Shanghai Co ltd
Priority to CN202210143477.XA priority Critical patent/CN114584543A/en
Publication of CN114584543A publication Critical patent/CN114584543A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/34Network arrangements or protocols for supporting network services or applications involving the movement of software or configuration parameters 

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention provides a web-based resource quick access method, which comprises the following steps: creating a separate JavaScript file and adding the file into a Worker; starting the Worker after the Worker executes the initial task; receiving an execution task sent by a main thread calling Worker. postMessage (); after receiving the task execution message, running a thread task and storing the obtained communication data into a medium; and returning the communication data to the main thread after the main thread monitors that the communication data is successfully stored through the onmessage. The invention adopts a browser thread mechanism to improve the speed of acquiring the content by the network and reduce the overhead flow, solves the problems that the UI of the page is white and the downtime data of the server cannot be stored, and optimizes the access performance of the page data.

Description

Web-based resource quick access method, system, medium and equipment
Technical Field
The present invention relates to the field of resource access, and in particular, to a method, system, medium, and device for fast access to resources based on the web.
Background
With the rise of Web2.0, Web application programs are used in B/S applications in a mode similar to a C/S architecture in a large scale, and User Interfaces (UI) of pages of the Web application programs are rendered by a webpage front end JS language, so that the webpage front end and a server are really separated in collaboration, and the collaboration efficiency is greatly improved.
The Web page front-end development is a project for creating a Web page or a front-end interface such as Wap and the like to present the Web page or the Wap and the like to a user, and in the presenting process, when the page loading is slow, the request time is too long, the page 404 and the like block the response of a browser, that is, when the user browses a home decoration information flow page, the user usually wants to see the content of the page faster, but because the page loading is slow and the like, the time consumption is long, the purpose of rapidly opening the page cannot be achieved, and the user experience is greatly influenced.
Disclosure of Invention
In view of the above-mentioned shortcomings in the prior art, it is an object of the present invention to provide a method, system, storage medium and device for fast access to web-based resources, which solve the above problems in the prior art.
To achieve the above and other related objects, the present invention provides a method for fast web-based resource access, comprising: creating a separate JavaScript file and adding the file into a Worker; starting the Worker after the Worker executes the initial task; receiving an execution task sent by a main thread calling Worker. postMessage (); after receiving the task execution message, running a thread task and storing the obtained communication data into a medium; and returning the communication data to the main thread after the main thread monitors that the communication data is successfully stored through the onmessage.
In an embodiment of the present invention, the method further includes: and accessing a network in an XML mode to acquire the communication data and storing the communication data in a browser locatorage.
In an embodiment of the present invention, the method further includes: after receiving an execution task, judging whether the communication data exists in a service container according to the communication data file name, if so, intercepting the execution task through a Fetch, and returning the communication data in the service container to a main thread; if not, executing the task, receiving the communication data sent by the server, and caching the obtained communication data into a service container, wherein the server modifies the name of the resource file by using an md5 key mode before sending the communication data; and automatically deleting the communication data in the service container after the time reaches a preset value after the cache.
In an embodiment of the present invention, the method further includes: carrying out data type conversion on the communication data; sending the converted communication data to a main thread; and restoring the data type of the communication data.
In an embodiment of the present invention, the method further includes: the converted data type includes binary data, Objects.
In an embodiment of the present invention, the method further includes: and closing the Worker after the communication data is returned to the main thread.
In an embodiment of the present invention, the method further includes: the communication data types entering the cache comprise JavaScript files, html files and JSON files.
To achieve the above and other related objects, the present invention provides a web-based resource access system, comprising: the creating module is used for creating a Worker; a receiving module, configured to receive an execution task sent by a main thread calling worker. The execution module is used for executing the received execution task sent by the main thread; the storage module is used for storing the communication data acquired by the execution task into a medium; and the sending module is used for returning the communication data to the main thread.
To achieve the above and other related objects, the present invention provides a computer-readable storage medium, in which a computer program is stored, and the computer program realizes the fast web-based resource access method when being loaded and executed by a processor.
To achieve the above and other related objects, the present invention provides an electronic device, comprising: a processor, a memory, and a communication interface; wherein the memory is for storing a computer program; the processor is used for loading and executing the computer program to enable the electronic equipment to execute the quick web-based resource access method; the communication interface is used for realizing communication between the access device and other equipment.
As described above, according to the method, the system, the medium and the device for quickly accessing resources based on the web, provided by the invention, aiming at the problems that the response of a browser is blocked due to slow page loading, overlong request time, page 404 and the like in the front-end page rendering process, a browser thread mechanism is adopted to improve the speed of acquiring contents by a network and reduce the overhead flow, and meanwhile, the problems that a page UI is blank and server down data cannot be stored are solved, and the page data access performance is optimized.
Drawings
Fig. 1 is a flowchart illustrating a method for fast web-based resource access according to an embodiment of the present invention.
Fig. 2 is a schematic block diagram of a web-based resource access system according to an embodiment of the present invention.
Fig. 3 is a schematic structural diagram of an electronic device according to an embodiment of the invention.
Detailed Description
The embodiments of the present invention are described below with reference to specific embodiments, and other advantages and effects of the present invention will be easily understood by those skilled in the art from the disclosure of the present specification. The invention is capable of other and different embodiments and of being practiced or of being carried out in various ways, and its several details are capable of modification in various respects, all without departing from the spirit and scope of the present invention. It is to be noted that the features in the following embodiments and examples may be combined with each other without conflict. 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 noted that the drawings provided in the following embodiments are only for illustrating the basic idea of the present invention, and the components related to the present invention are only shown in the drawings rather than drawn according to the number, shape and size of the components in actual implementation, and the type, quantity and proportion of the components in actual implementation may be changed freely, and the layout of the components may be more complicated.
The invention provides a method, a system, a medium and equipment for quickly accessing resources based on a web, and aims to solve the problems that in the prior art, the maximum value of client investment cannot be played, the whole order conversion rate cannot be improved and the incentive effect cannot be created due to two methods of manual order distribution by a client service supervisor and order distribution by an automatic order distribution system according to the amount of orders.
As shown in fig. 1, the present embodiment provides a method for fast accessing a web-based resource, which includes the following steps:
s11: create a separate JavaScript file and add the file to a Worker.
Specifically, in the JavaScript file or the global entry file corresponding to the front-end display, a new name is adopted, and a Worker () constructor is called to create a new Worker, for example:
Const Worker=new Worker(‘xxx.js’)。
s12: the Worker is started after it executes the initial task.
Specifically, the Worker is started after necessary initialization tasks are executed in the Worker thread.
S13: receive the main thread and call the executive task that worker.
The main thread calls a Worker message () method, sends an execution task to the Worker, and informs the Worker to execute the task without affecting the main thread.
S14: and after receiving the task execution message, running the thread task and storing the acquired communication data into a medium.
Specifically, after receiving a task sent by the main thread, the Worker acquires the communication data through the access network and stores the communication data into the browser locartoage, for example, the Worker accesses the network through an XML manner to acquire the communication data required by the main thread.
Preferably, the communication data is stored in the service container after the new communication data is acquired. The main thread monitors whether the communication data to be acquired exists in a service container or not through an onmessage, the monitoring mode is that whether the communication data exists in the service container or not is judged according to the name of the communication data file to be acquired, if so, a Worker intercepts an execution task sent by the main thread through a Fetch and returns the communication data in the service container to the main thread; if not, the Worker executes the task after receiving the task, receives the communication data sent by the server, and caches the acquired new communication data in the service container, and it should be noted that the server modifies the resource file name of the communication data by using an md5 key mode before sending the communication data. The communication data types which can be cached comprise JavaScript files, html files and JSON files.
Further, if new communication data are not received for a long time, the Worker cache works to enter a sleep mode, and automatically enters the sleep mode, so that the resource waste of the browser is reduced. And if new communication data are generated, triggering a cache mechanism to cache the communication data.
Preferably, a timing task is set in the main thread, all files in the service container are acquired, the file name is decrypted by using md5 to acquire a file cache timestamp, the time difference between the current timestamp and the cache timestamp is calculated, and the file is automatically deleted by the timing task when the time difference reaches the time value of the set timing task.
S15: and returning the communication data to the main thread after the main thread monitors that the communication data is successfully stored through the onmessage.
Specifically, after the main thread monitors the required communication data in the service container or other media through the onmessage, the Worker first performs data type conversion on the communication data, and may convert the communication data type into binary data and Transferable Objects, such as File, Blob, and phone number.
Further, the converted communication data is sent to the main thread through postMessage (). And restoring the data type of the communication data after the data is sent.
Further, if the Worker successfully returns the communication data, the Worker is closed through the Worker. Otherwise, the main thread is notified of the failure.
All or part of the steps for implementing the above method embodiments may be performed by hardware associated with a computer program. Based upon such an understanding, the present invention also provides a computer program product comprising one or more computer instructions. The computer instructions may be stored in a computer readable storage medium. The computer-readable storage medium can be any available medium that a computer can store or a data storage device, such as a server, a data center, etc., that is integrated with one or more available media.
Referring to fig. 2, the present embodiment provides a web-based resource access system 20, which is installed in an electronic device as a piece of software to execute the method for fast accessing web-based resources in the foregoing method embodiments when running. Since the technical principle of the embodiment of the system is similar to that of the embodiment of the method, repeated description of the same technical details is omitted.
The web-based resource access system 20 of the present embodiment specifically includes: the device comprises a creating module 21, a receiving module 22, an executing module 23, a storing module 24 and a sending module 25. The creating module 21 is used for creating a Worker; the receiving module 22 is configured to receive an execution task sent by a main thread calling worker. The execution module 23 is configured to execute the received execution task sent by the main thread; the storage module 24 is used for storing the communication data acquired by the execution task into a medium; the sending module 25 is configured to return the communication data to the main thread.
Those skilled in the art should understand that the division of the modules in the embodiment of fig. 2 is only a logical division, and the actual implementation can be fully or partially integrated into one or more physical entities. And the modules can be realized in a form that all software is called by the processing element, or in a form that all the modules are realized in a form that all the modules are called by the processing element, or in a form that part of the modules are called by the hardware. For example, the execution module 22 may be a separate processing element, or may be integrated in a chip, or may be stored in a memory in the form of program code, and the function of the execution module 22 is called and executed by a certain processing element. Other modules are implemented similarly. The processing element described herein may be an integrated circuit having signal processing capabilities. In implementation, each step of the above method or each module above may be implemented by an integrated logic circuit of hardware in a processor element or an instruction in the form of software.
Referring to fig. 3, the embodiment provides an electronic device, which may be a portable computer, a smart phone, a tablet computer, or the like. In detail, the electronic device comprises at least, connected by a bus 31: a memory 32, a processor 33, and a communication interface 34, wherein the communication interface 34 is used for implementing communication between the data access apparatus and other devices, the memory 32 is used for storing computer programs, and the processor 33 is used for executing the computer programs stored in the memory 32 to execute all or part of the steps in the foregoing method embodiments.
The above-mentioned system bus may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The system bus may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus. The communication interface is used for realizing communication between the database access device and other equipment (such as a client, a read-write library and a read-only library). The Memory may include a Random Access Memory (RAM), and may further include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, or discrete hardware components.
In summary, according to the method, the system, the medium and the device for fast accessing resources based on the web, provided by the invention, aiming at the problems that the response of a browser is blocked, such as slow page loading, overlong request time, page 404 and the like, in the process of appearing a front-end page, a browser thread mechanism is adopted to improve the speed of obtaining content by a network and reduce the overhead flow, and meanwhile, by intercepting and modifying access and resource requests, resources are cached in a fine-grained manner, a decryption algorithm can be accelerated, and computing resources can be saved; the data loading speed is increased, and the browser can render a page after obtaining the data more quickly; memory accumulation of the browser is reduced; the problems that the UI of the page is white and the data about the downtime of the server cannot be stored are solved, and the access performance of the page data is optimized. Therefore, the invention effectively overcomes various defects in the prior art and has high industrial utilization value.
The foregoing embodiments are merely illustrative of the principles and utilities of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or change the above-mentioned embodiments without departing from the spirit and scope of the present invention. Accordingly, it is intended that all equivalent modifications or changes which can be made by those skilled in the art without departing from the spirit and technical spirit of the present invention be covered by the claims of the present invention.

Claims (10)

1. A method for quickly accessing resources based on web is characterized by comprising the following steps:
creating a separate JavaScript file and adding the file into a Worker;
starting the Worker after the Worker executes the initial task;
receiving an execution task sent by a main thread calling Worker. postMessage ();
after receiving the task execution message, running a thread task and storing the obtained communication data into a medium;
and returning the communication data to the main thread after the main thread monitors that the communication data is successfully stored through the onmessage.
2. The method of claim 1, further comprising:
and accessing a network in an XML mode to acquire the communication data and storing the communication data in a browser locatorage.
3. The method of claim 1, further comprising:
after receiving an execution task, judging whether the communication data exists in a service container according to the communication data file name, if so, intercepting the execution task through a Fetch, and returning the communication data in the service container to a main thread; if not, executing the task after receiving the task, receiving the communication data sent by the server, and caching the obtained communication data into a service container, wherein the server modifies the name of the resource file by using an md5 key mode before sending the communication data; and the communication data in the service container is automatically deleted after the time after caching reaches a preset value.
4. The method of claims 1-3, further comprising:
carrying out data type conversion on the communication data;
sending the converted communication data to a main thread;
and restoring the data type of the communication data.
5. The method of claim 4, further comprising:
the converted data type includes binary data, Objects.
6. The method of claim 1, further comprising:
and closing the Worker after the communication data is returned to the main thread.
7. The method of claim 3, further comprising:
the communication data types entering the cache comprise JavaScript files, html files and JSON files.
8. A web-based quick resource access system, the system comprising:
the creating module is used for creating a Worker;
the receiving module is used for receiving an execution task sent by calling the worker.
The execution module is used for executing the received execution task;
the storage module is used for executing the received execution task sent by the main thread;
and the sending module is used for returning the communication data to the main thread.
9. A computer-readable storage medium, in which a computer program is stored, which, when loaded and executed by a processor, carries out a method for fast access to web-based resources according to any one of claims 1 to 7.
10. An electronic device, comprising: a processor, a memory, and a communication interface; wherein the content of the first and second substances,
the memory is used for storing a computer program;
the processor is used for loading and executing the computer program to enable the electronic equipment to execute the web-based resource quick access method according to any one of claims 1 to 7;
the communication interface is used for realizing communication between the access device and other equipment.
CN202210143477.XA 2022-02-16 2022-02-16 Web-based resource quick access method, system, medium and equipment Pending CN114584543A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210143477.XA CN114584543A (en) 2022-02-16 2022-02-16 Web-based resource quick access method, system, medium and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210143477.XA CN114584543A (en) 2022-02-16 2022-02-16 Web-based resource quick access method, system, medium and equipment

Publications (1)

Publication Number Publication Date
CN114584543A true CN114584543A (en) 2022-06-03

Family

ID=81770666

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210143477.XA Pending CN114584543A (en) 2022-02-16 2022-02-16 Web-based resource quick access method, system, medium and equipment

Country Status (1)

Country Link
CN (1) CN114584543A (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110016169A1 (en) * 2009-07-20 2011-01-20 Matthew Cahill Rendering a web page using content communicated to a browser application from a process running on a client
US20110264759A1 (en) * 2010-04-21 2011-10-27 Microsoft Corporation Optimized caching for large data requests
CN103870539A (en) * 2014-02-20 2014-06-18 小米科技有限责任公司 Text preprocessing method and device
CN110287432A (en) * 2019-06-28 2019-09-27 北京金山安全软件有限公司 Network information processing method and device and electronic equipment
CN110929194A (en) * 2019-11-21 2020-03-27 山东鲁能软件技术有限公司 Abstract algorithm-based static resource file cache control method and system
CN111475180A (en) * 2019-01-24 2020-07-31 北京京东尚科信息技术有限公司 Method and system for updating client cache
US20200310857A1 (en) * 2019-03-29 2020-10-01 Hewlett Packard Enterprise Development Lp Launch web browser applications in microservice-based containers
US20210067494A1 (en) * 2019-09-04 2021-03-04 Microsoft Technology Licensing, Llc Secure communication between web frames
CN113468448A (en) * 2020-03-31 2021-10-01 腾讯科技(深圳)有限公司 Page rendering method and device
CN113961832A (en) * 2021-10-19 2022-01-21 广州虎牙科技有限公司 Page rendering method, device, equipment, storage medium and program product

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20110016169A1 (en) * 2009-07-20 2011-01-20 Matthew Cahill Rendering a web page using content communicated to a browser application from a process running on a client
US20110264759A1 (en) * 2010-04-21 2011-10-27 Microsoft Corporation Optimized caching for large data requests
CN103870539A (en) * 2014-02-20 2014-06-18 小米科技有限责任公司 Text preprocessing method and device
CN111475180A (en) * 2019-01-24 2020-07-31 北京京东尚科信息技术有限公司 Method and system for updating client cache
US20200310857A1 (en) * 2019-03-29 2020-10-01 Hewlett Packard Enterprise Development Lp Launch web browser applications in microservice-based containers
CN110287432A (en) * 2019-06-28 2019-09-27 北京金山安全软件有限公司 Network information processing method and device and electronic equipment
US20210067494A1 (en) * 2019-09-04 2021-03-04 Microsoft Technology Licensing, Llc Secure communication between web frames
CN110929194A (en) * 2019-11-21 2020-03-27 山东鲁能软件技术有限公司 Abstract algorithm-based static resource file cache control method and system
CN113468448A (en) * 2020-03-31 2021-10-01 腾讯科技(深圳)有限公司 Page rendering method and device
CN113961832A (en) * 2021-10-19 2022-01-21 广州虎牙科技有限公司 Page rendering method, device, equipment, storage medium and program product

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
胡晶;董航;: "HTML5核心Web技术分析", 长春工业大学学报(自然科学版), no. 5 *

Similar Documents

Publication Publication Date Title
US10325009B2 (en) Method and apparatus for using custom component parsing engine to parse tag of custom component
CN110865888B (en) Resource loading method and device, server and storage medium
US8346889B1 (en) Event-driven module loading
US9069549B2 (en) Machine processor
US20140365861A1 (en) Prefetching binary data for use by a browser plugin
CN112930530B (en) Client application for network application execution
US20180084075A1 (en) Request cache to improve web applications performance
CN109800370A (en) Display methods, device, computer equipment and the storage medium of Webpage
CN112612982A (en) Webpage preloading method and device and computer equipment
US20140280693A1 (en) Font delivery service
CN109325192B (en) Advertisement anti-shielding method and device
CN103559097A (en) Inter-process communication method and device in browser and browser
CN103377194A (en) Method, device and browser for accelerating access to web pages
CN110750744A (en) Page presentation method and device
US9448823B2 (en) Provision of a download script
CN114584543A (en) Web-based resource quick access method, system, medium and equipment
CN111177600A (en) Built-in webpage loading method and device based on mobile application
CN115758004A (en) Webpage table display method and device, computer readable medium and electronic equipment
US8793663B2 (en) Smart cache for a server test environment in an application development tool
CN114647411A (en) Programming interface loading method and device, electronic equipment and storage medium
CN111427654B (en) Instruction processing method and device
CN112860720B (en) Storage capacity updating method and device
EP3642727A1 (en) Resource pre-fetch using age threshold
CN112579282A (en) Data processing method, device, system and computer readable storage medium
CN112433778A (en) Mobile equipment page display method and device, electronic equipment and storage medium

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