CN111224880A - Interface data acquisition method and device for single-page application and storage medium - Google Patents

Interface data acquisition method and device for single-page application and storage medium Download PDF

Info

Publication number
CN111224880A
CN111224880A CN201911414852.4A CN201911414852A CN111224880A CN 111224880 A CN111224880 A CN 111224880A CN 201911414852 A CN201911414852 A CN 201911414852A CN 111224880 A CN111224880 A CN 111224880A
Authority
CN
China
Prior art keywords
interface
request
interface data
routing
page
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
CN201911414852.4A
Other languages
Chinese (zh)
Inventor
张伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Absolute Health Ltd
Original Assignee
Beijing Absolute Health Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Absolute Health Ltd filed Critical Beijing Absolute Health Ltd
Priority to CN201911414852.4A priority Critical patent/CN111224880A/en
Publication of CN111224880A publication Critical patent/CN111224880A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/742Route cache; Operation thereof
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • 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]

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a method, a device and a storage medium for acquiring interface data of single-page application, wherein the method comprises the steps of sending an interface pre-request to a server based on parameters required by a routing page interface corresponding to a pre-configured routing script file when the routing script file is loaded, receiving and caching interface data returned by the server aiming at the interface pre-request, searching the interface data corresponding to the interface request from the cached interface data if the routing page is mounted and the interface request is prepared to be sent, extracting the searched interface data corresponding to the interface request, and applying the extracted interface data to a routing page. The embodiment of the invention can effectively reduce the waiting time of the interface request initiated when the routing page is mounted, avoid the problem of jitter caused by slow acquisition of interface data in the routing page and improve the experience of a user for browsing the page.

Description

Interface data acquisition method and device for single-page application and storage medium
Technical Field
The invention relates to the technical field of web front-end design, in particular to a method and a device for acquiring interface data of single-page application and a storage medium.
Background
Generally, in a single-page application, an interface request of each page needs to be initiated only after the routing js of the page is loaded and rendered, for example, a routing page is mounted after the routing js (javascript) is loaded, and then the interface request is performed after the routing page is mounted, which not only causes the page rendering to generate obvious jitter, but also causes a user to feel that the page is loaded slowly.
At present, a Server Side Rendering (SSR) technology is adopted, a html string is generated from a component or a page through a Server, and then the html string is sent to a browser, and finally a static mark is "mixed" to be a completely interactive application program on a client Side. Or some pre-loadable data is put into the global variable in advance for use through a server-side rendering technology. However, the above scheme can only solve the problem of blank screen of the page accessed from the first screen, and when other pages are continuously accessed, the situation of page jitter caused by loading the route js and rendering the page and then performing the interface request still exists, and the running cost and the learning cost of the server are increased, and the development condition of the front end of the web is limited.
Disclosure of Invention
In view of this, the embodiment of the present invention provides an interface data obtaining method for a single-page application, which can achieve the purposes of reducing the request duration of an interface request and improving the obtaining and displaying efficiency of interface data in a routing page.
According to an aspect of the embodiments of the present invention, there is provided a method for acquiring interface data of a single-page application, including:
when a routing script file is loaded, sending an interface pre-request to a server based on a parameter required by a routing page interface corresponding to the routing script file which is configured in advance;
receiving interface data returned by the server aiming at the interface pre-request, and caching the interface data;
if the routing page is mounted and an interface request is ready to be sent, searching interface data corresponding to the interface request from cached interface data;
and extracting the interface data corresponding to the searched interface request, and applying the interface data to the routing page.
Optionally, after sending an interface pre-request to the server based on the pre-configured parameters required by the routing page interface corresponding to the routing script file, the method further includes:
caching a pre-request state corresponding to the interface pre-request, wherein the pre-request state comprises pre-request completion or pre-request in-process.
Optionally, extracting the found interface data corresponding to the interface request includes:
if the interface data corresponding to the interface request is found, analyzing whether the pre-request state corresponding to the cached interface pre-request is pre-request completion;
if the pre-request state is pre-request completion, extracting the found interface data corresponding to the interface request;
and if the pre-request state is not the pre-request completion, after waiting for the pre-request state to become the pre-request completion within a specified time, extracting the found interface data corresponding to the interface request.
Optionally, the pre-configured parameters required by the routing page interface corresponding to the routing script file include:
at least one of the name of the routing page where the interface is located, the unique identifier of the interface and the path of the interface.
Optionally, the searching for the interface data corresponding to the interface request from the cached interface data includes: and searching interface data corresponding to the interface request from the cached interface data according to at least one of the unique interface identifier and the interface path of the request interface.
Optionally, before caching the interface data, the method further includes: and configuring the caching time of the interface data based on the change frequency of the interface data content corresponding to the interface needing to be requested in advance on the routing page.
Optionally, after searching the interface data corresponding to the interface request from the cached interface data, the method further includes: if the interface data corresponding to the interface request is not found from the cached interface data, sending the interface request to the server; and receiving interface data returned by the server aiming at the interface request and applying the interface data to the routing page.
According to another aspect of the embodiments of the present invention, there is also provided an interface data acquiring apparatus for a single-page application, including:
the sending module is suitable for sending an interface pre-request to a server side based on the pre-configured parameters required by the routing page interface corresponding to the routing script file when the routing script file is loaded;
the cache module is suitable for receiving interface data returned by the server aiming at the interface pre-request and caching the interface data;
the searching module is suitable for searching interface data corresponding to the interface request from the cached interface data if the mounting of the routing page is finished and the interface request is ready to be sent;
and the extracting module is suitable for extracting the searched interface data corresponding to the interface request and applying the extracted interface data to the routing page.
Optionally, the cache module is further adapted to:
caching a pre-request state corresponding to the interface pre-request, wherein the pre-request state comprises pre-request completion or pre-request in-process.
Optionally, the extraction module is further adapted to:
if the interface data corresponding to the interface request is found, analyzing whether the pre-request state corresponding to the cached interface pre-request is pre-request completion;
if the pre-request state is pre-request completion, extracting the found interface data corresponding to the interface request;
and if the pre-request state is not the pre-request completion, after waiting for the pre-request state to become the pre-request completion within a specified time, extracting the found interface data corresponding to the interface request.
Optionally, the pre-configured parameters required by the routing page interface corresponding to the routing script file include: at least one of the name of the routing page where the interface is located, the unique identifier of the interface and the path of the interface.
The lookup module is further adapted to: and searching interface data corresponding to the interface request from the cached interface data according to at least one of the unique interface identifier and the interface path of the request interface.
Optionally, the apparatus further includes a configuration module adapted to configure a cache time of the interface data based on a change frequency of interface data content corresponding to an interface that needs to be requested in advance on the routing page.
The device also comprises a receiving module; the sending module is further adapted to send the interface request to the server if the interface data corresponding to the interface request is not found from the cached interface data; the receiving module is suitable for receiving the interface data returned by the server aiming at the interface request and applying the interface data to the routing page.
According to still another aspect of embodiments of the present invention, there is also provided a computer-readable storage medium storing computer program code, which when run on a computing device, causes the computing device to execute the interface data acquisition method of a single-page application described in any of the above embodiments.
According to still another aspect of the embodiments of the present invention, there is also provided a computing device including: a processor; a memory storing computer program code; the computer program code, when executed by the processor, causes the computing device to perform the interface data acquisition method of a single-page application as described in any of the embodiments above.
In the embodiment of the invention, when the routing script file starts to be loaded, the loading time of the routing script file is fully utilized, the interface pre-request is synchronously sent to the server side based on the parameters required by the routing page interface corresponding to the pre-configured routing script file, and the returned interface data is cached, so that the cached interface data can be directly and quickly acquired when the interface request is prepared to be sent subsequently, the waiting time of the interface request initiated when the routing page is mounted is effectively reduced, the problem of jitter caused by the slow acquisition of the interface data in the routing page is avoided, and the page browsing experience of a user is improved.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
The above and other objects, advantages and features of the present invention will become more apparent to those skilled in the art from the following detailed description of specific embodiments thereof, taken in conjunction with the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description, serve to explain the principles of the invention.
The invention will be more clearly understood from the following detailed description, taken with reference to the accompanying drawings, in which:
fig. 1 is a flowchart illustrating an interface data obtaining method for a single-page application according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating an interface data obtaining method for a single-page application according to another embodiment of the present invention;
FIG. 3 is a flowchart illustrating an overall interface data acquisition process of a single-page application according to an embodiment of the present invention;
FIG. 4 is a schematic structural diagram of an interface data acquisition apparatus for a single-page application according to an embodiment of the present invention; and
fig. 5 is a schematic structural diagram of an interface data acquisition apparatus for a single-page application according to another embodiment of the present invention.
Detailed Description
Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that: the relative arrangement of the components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.
Meanwhile, it should be understood that the sizes of the respective portions shown in the drawings are not drawn in an actual proportional relationship for the convenience of description.
The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
Techniques, methods, and apparatus known to those of ordinary skill in the relevant art may not be discussed in detail but are intended to be part of the specification where appropriate.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, further discussion thereof is not required in subsequent figures.
Embodiments of the invention are operational with numerous other general purpose or special purpose computing system environments or configurations. Examples of well known computing systems, environments, and/or configurations that may be suitable for use with the computer system/server include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, hand-held or laptop devices, microprocessor-based systems, set top boxes, programmable consumer electronics, network pcs, minicomputer systems, mainframe computer systems, distributed cloud computing environments that include any of the above systems, and the like.
The computer system/server may be described in the general context of computer system-executable instructions, such as program modules, being executed by a computer system. Generally, program modules may include routines, programs, objects, components, logic, data structures, etc. that perform particular tasks or implement particular abstract data types. The computer system/server may be practiced in distributed cloud computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed cloud computing environment, program modules may be located in both local and remote computer system storage media including memory storage devices.
An embodiment of the present invention provides an interface data obtaining method for a single-page application, and fig. 1 shows a flowchart of the interface data obtaining method for the single-page application according to an embodiment of the present invention, and referring to fig. 1, the method may include the following steps S102 to S108.
Step S102, when the route script file is loaded, an interface pre-request is sent to the server side based on the parameters required by the route page interface corresponding to the route script file configured in advance.
The interface pre-request in this step is a real interface request sent to the server.
And step S104, receiving the interface data returned by the server aiming at the interface pre-request, and caching the interface data.
And step S106, if the mounting of the routing page is finished and the interface request is ready to be sent, searching interface data corresponding to the interface request from the cached interface data.
Step S108, extracting the interface data corresponding to the searched interface request, and applying the interface data to the routing page.
In the embodiment of the invention, when the routing script file starts to be loaded, the loading time of the routing script file is fully utilized, the interface pre-request is synchronously sent to the server based on the parameters required by the routing page interface corresponding to the pre-configured routing script file, and the returned interface data is cached, so that the cached interface data can be directly and quickly acquired when the interface request is prepared to be sent subsequently, the waiting time of the interface request initiated when the routing page is mounted is effectively reduced, the problem of jitter caused by the slow acquisition of the interface data in the routing page is avoided, and the page browsing experience of a user is improved.
Referring to step S102 above, in the embodiment of the present invention, to reduce the request time of the interface request and improve the efficiency of obtaining the interface data, when the routing script file starts to be loaded, the interface pre-request may be sent to the server side in parallel, so as to request the corresponding interface data from the server side in advance through the interface pre-request. The routing script file is a routing JS (javascript) file, and usually one routing page corresponds to one routing JS file.
In this embodiment, which routing pages and which interfaces on the routing pages need to perform the interface pre-request may be configured in advance through parameters, and then the interface pre-request is sent to the server according to the configured parameters for the interfaces that need to be pre-requested on the routing pages that include the pre-request to be interfaced.
Referring to step S104, in the embodiment of the present invention, after receiving the interface data returned by the server for the interface pre-request, the interface data is cached, so that the interface data is not required to be acquired from the server for the subsequently issued interface request, but the corresponding interface data is directly searched from the cached data, so as to improve the efficiency of acquiring the interface data. In an alternative embodiment, the interface data requested by the interface pre-request may be cached in the cache pool, and the interface data requested by the different interface pre-requests may be cached separately in the cache pool.
In the embodiment of the invention, the caching time of the interface data can be configured in advance, and the caching time is reasonably configured, so that the caching data can be requested by the interface request in the following and the caching space is effectively utilized, and the excessive occupation of the caching space is avoided. In an optional embodiment, the cache time of the interface data may be configured based on a change frequency of interface data content corresponding to an interface that needs to be requested in advance on the routing page, that is, different cache times may be set for the change frequencies of different interface data contents, and in general, the higher the change frequency of the interface data content is, the shorter the cache time of the configured interface data is. For example, interface data corresponding to some interfaces of the routing page may change quickly, and the corresponding cache time may be set to be shorter, for example, 1.5 milliseconds, 2 milliseconds, and the like, and if the interface data corresponding to the interfaces do not change much, the corresponding cache time may be set to be longer, for example, 58 milliseconds, 60 milliseconds, and the like, which is not limited in this embodiment.
In order to avoid the configuration problem of the interface that needs to be requested in advance, in an optional embodiment of the present invention, whether the interface data is requested by the interface request within the cache time may be monitored by using an observer mode, and if the cache time of the interface data is passed and the cached interface data is still not used, it may be prompted that the interface that needs to be requested in advance has a configuration error, so that unnecessary sending of the interface pre-request is reduced.
In an optional embodiment of the present invention, the parameters required by the routing page interface corresponding to the preconfigured routing script file may include at least one of a routing page name of the interface, an interface unique identifier, an interface path, and the like. In this embodiment, the name of the routing page where the interface is located may indicate which routing pages contain the interface to be pre-requested by the interface. The unique interface identifier may include an interface name, a URL (Uniform Resource Locator) of the interface, and the like. The embodiment of the present invention does not limit the specific parameters of the pre-configured interface.
In this embodiment, when step S106 is executed to search the interface data corresponding to the interface request from the cached interface data, the interface data corresponding to the interface request may be quickly searched from the cached interface data according to at least one of the unique interface identifier and the interface path of the interface to be requested.
Referring to step S106, in the embodiment of the present invention, the routing page is rendered during the mounting process of the routing page, and after the rendering of the routing page is completed, the initialization of the data related to the interface request is performed by executing the hook function mount, and the sending of the interface request is triggered. For example, after the route script file loading in step S104 above is performed, the entire frame of the route page is rendered in the process of executing to the route page mounting. The interface request is intercepted so that the interface request is not sent to the server, the corresponding interface data is searched from the cached interface data, and the searched interface data is applied to the routing page. For example, the interface data required to be displayed by a pre-request interface included in a home page of a certain website is the number of users of the website, and after the frame rendering of the home page is completed, the number of users of the website requested by the pre-request is found from the cached interface data, so that the number of users of the website can be quickly displayed in the home page.
In this embodiment, the interface request may be intercepted in a decoration mode or a proxy mode, and the process of searching the cached interface data is directly executed after the interface request is sent.
In conjunction with the above embodiment, another method for acquiring interface data of a single-page application is further provided in the embodiment of the present invention, and fig. 2 shows a schematic flow chart of the method for acquiring interface data of a single-page application in another embodiment of the present invention, and referring to fig. 2, the method may include the following steps S202 to S218.
Step S202, when the routing script file is loaded, an interface pre-request is sent to the server based on the parameters required by the routing page interface corresponding to the pre-configured routing script file.
In this step, the configuration of the parameters required by the routing page interface may refer to the above embodiments, and details are not described here.
Step S204, caching a pre-request state corresponding to the interface pre-request, wherein the pre-request state comprises pre-request completion or pre-request in-process.
In the step, the pre-request state corresponding to the interface pre-request is cached, whether the caching of the requested interface data of the pre-request is completed or not can be conveniently analyzed subsequently according to the pre-request state, and if the pre-request state is the pre-request completion, the caching of the corresponding interface data is completed. If the pre-request state is in the process of pre-request, the pre-request state indicates that the corresponding interface data is in the process of caching.
Step S206, receiving the interface data returned by the server aiming at the interface pre-request, and caching the interface data.
Step S208, if the route page is mounted and an interface request is ready to be sent, searching whether interface data corresponding to the interface request exists in the cached interface data. If yes, go to step S210. If not, step S212 is executed to send the interface request to the server, and step S214 is executed to receive the interface data returned by the server for the interface request and apply the interface data to the routing page.
In the embodiment of the present invention, whether interface data corresponding to an interface request exists or not is searched from the cached interface data, whether the interface request hits the cached interface data or not is checked, and if the interface request does not hit the cached interface data, that is, the cached interface data does not exist the interface data corresponding to the interface request, it may be that the corresponding interface does not send a pre-request to the server in advance, or that the pre-request fails to be sent.
Step S210, analyzing whether the pre-request state corresponding to the cached interface pre-request is pre-request complete. If yes, go to step S216. If not, go to step S218.
Step S216, extracting the interface data corresponding to the searched interface request, and applying the interface data to the routing page.
Step S218, after the pre-request state is changed to the pre-request state within the specified time, extracting the interface data corresponding to the found interface request, and applying the extracted interface data to the routing page.
In this step, in order to avoid that the pre-request interface has a problem and cannot complete the pre-request all the time, the pre-request completion time can be limited by setting a specified time range, if the pre-request is completed within the specified time, the data obtained by the pre-request can be normally extracted, and if the pre-request cannot be completed within the specified time all the time, a prompt that the corresponding interface has a problem can be sent.
With reference to fig. 3 in conjunction with the above embodiments, an interface data acquisition process for a single-page application will now be described with a specific embodiment.
And simultaneously sending the interface pre-request to the server side in parallel while loading the JS file. The interface pre-request is a real interface request sent to the server, and when the interface pre-request is sent, the interface pre-request is sent to the server based on the pre-configured parameters required by the interface. And receiving interface data returned by the server and caching the interface data into a buffer pool. In this embodiment, before the JS file is loaded, the single-page application executes some common resources, such as CSS (Cascading Style Sheets) files, page resources, picture resources, and the like.
And after the route page is mounted, intercepting the interface request when the interface request is ready to be sent, and judging whether the interface request hits interface data in the cache pool or not. And if the interface data hit in the cache pool, analyzing whether the pre-request state corresponding to the interface data hit in the cache pool is pre-request completion. If the interface data interface in the cache pool is not hit, sending an interface request to the server (the interface request is completed within a time of usually less than a few milliseconds), receiving interface data returned by the server, and applying the interface data to the routing page. After the page mount is finished, initializing the data related to the interface request by executing the hook function mount, and triggering the sending of the interface request.
And if the pre-request state corresponding to the interface data hit in the cache pool is analyzed to be pre-request completion, directly extracting corresponding interface data in the cache pool, and applying the interface data to the routing page. If the pre-request state is not the pre-request completion, extracting corresponding interface data in the cache pool after the pre-request state is changed into the pre-request completion (normally, the interface pre-request is completed within a time of less than a few milliseconds), and applying the interface data to the routing page. The promise body of the interface pre-request state machine is put into a cache pool, and the pre-request state can be judged according to the state of the state machine.
Based on the same inventive concept, the embodiment of the invention also provides an interface data acquisition device for the single-page application. Fig. 4 shows a schematic structural diagram of an interface data acquiring apparatus for a single-page application according to an embodiment of the present invention, and referring to fig. 4, the interface data acquiring apparatus for a single-page application may include a sending module 410, a caching module 420, a searching module 430, and an extracting module 440, specifically:
the sending module 410 is adapted to send an interface pre-request to the server based on the parameters required by the routing page interface corresponding to the pre-configured routing script file when the routing script file is loaded;
the cache module 420 is adapted to receive interface data returned by the server in response to the interface pre-request, and cache the interface data;
the searching module 430 is adapted to search interface data corresponding to the interface request from the cached interface data if the mounting of the routing page is completed and the interface request is ready to be sent;
the extracting module 440 is adapted to extract the interface data corresponding to the found interface request, and apply the extracted interface data to the routing page.
In an optional embodiment of the present invention, the caching module 420 is further adapted to cache a pre-request state corresponding to the interface pre-request, where the pre-request state includes pre-request completion or pre-request in progress.
In an optional embodiment of the present invention, the extracting module 440 is further adapted to, if the interface data corresponding to the interface request is found, analyze whether a pre-request state corresponding to the cached interface pre-request is a pre-request completion. And if the pre-request state is pre-request completion, extracting the interface data corresponding to the searched interface request. If the pre-request state is not the pre-request completion, the interface data corresponding to the searched interface request is extracted after the pre-request state is changed into the pre-request completion within the specified time.
Referring to fig. 5, in an alternative embodiment of the present invention, the interface data acquiring apparatus of the single-page application in fig. 4 above may further include a configuration module 450. The configuration module 450 is adapted to configure the cache time of the interface data based on the interface data content corresponding to the interface that needs to be requested in advance on the routing page, wherein the higher the change frequency of the interface data content is, the shorter the cache time of the interface data that is configured correspondingly is.
With continued reference to fig. 5, in an alternative embodiment of the present invention, the interface data acquisition apparatus of the single-page application in fig. 4 above may further include a receiving module 460. The sending module 410 is further adapted to send the interface request to the server if the interface data corresponding to the interface request is not found in the cached interface data. The receiving module 460 is adapted to receive the interface data returned by the server for the interface request and apply the interface data to the routing page.
In an optional embodiment of the present invention, the parameters required by the routing page interface corresponding to the preconfigured routing script file include at least one of routing page information, an interface unique identifier, and an interface path of the pre-request to be interfaced.
In an optional embodiment of the present invention, the searching module 430 is further adapted to search the interface data corresponding to the interface request from the cached interface data according to at least one of the unique interface identifier and the interface path of the request interface.
Based on the same inventive concept, an embodiment of the present invention further provides a computer-readable storage medium, which stores computer program codes, and when the computer program codes are run on a computing device, the computer program codes cause the computing device to execute the interface data obtaining method of the single-page application in any of the above embodiments.
Based on the same inventive concept, the embodiment of the invention also provides a computing device, which comprises a processor; a memory storing computer program code; the computer program code, when executed by a processor, causes a computing device to perform the interface data acquisition method of a single-page application in any of the embodiments above.
In the present specification, the embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts in the embodiments are referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The method and system of the present invention may be implemented in a number of ways. For example, the methods and systems of the present invention may be implemented in software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order for the steps of the method is for illustrative purposes only, and the steps of the method of the present invention are not limited to the order specifically described above unless specifically indicated otherwise. Furthermore, in some embodiments, the present invention may also be embodied as a program recorded in a recording medium, the program including machine-readable instructions for implementing a method according to the present invention. Thus, the present invention also covers a recording medium storing a program for executing the method according to the present invention.
The description of the present invention has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the invention in the form disclosed. Many modifications and variations will be apparent to practitioners skilled in this art. The embodiment was chosen and described in order to best explain the principles of the invention and the practical application, and to enable others of ordinary skill in the art to understand the invention for various embodiments with various modifications as are suited to the particular use contemplated.

Claims (12)

1. An interface data acquisition method for a single-page application is characterized by comprising the following steps:
when a routing script file is loaded, sending an interface pre-request to a server based on a parameter required by a routing page interface corresponding to the routing script file which is configured in advance;
receiving interface data returned by the server aiming at the interface pre-request, and caching the interface data;
if the routing page is mounted and an interface request is ready to be sent, searching interface data corresponding to the interface request from cached interface data;
and extracting the interface data corresponding to the searched interface request, and applying the interface data to the routing page.
2. The method according to claim 1, wherein after sending an interface pre-request to a server based on the pre-configured parameters required by the routing page interface corresponding to the routing script file, the method further comprises:
caching a pre-request state corresponding to the interface pre-request, wherein the pre-request state comprises pre-request completion or pre-request in-process.
3. The method according to claim 2, wherein extracting the found interface data corresponding to the interface request includes:
if the interface data corresponding to the interface request is found, analyzing whether the pre-request state corresponding to the cached interface pre-request is pre-request completion;
if the pre-request state is pre-request completion, extracting the found interface data corresponding to the interface request;
and if the pre-request state is not the pre-request completion, after waiting for the pre-request state to become the pre-request completion within a specified time, extracting the found interface data corresponding to the interface request.
4. The method according to any one of claims 1 to 3,
the pre-configured parameters required by the routing page interface corresponding to the routing script file comprise:
at least one of the name of the routing page where the interface is located, the unique identifier of the interface and the path of the interface;
and/or
The searching for the interface data corresponding to the interface request from the cached interface data includes:
and searching interface data corresponding to the interface request from the cached interface data according to at least one of the unique interface identifier and the interface path of the request interface.
5. The method according to any one of claims 1 to 3,
before caching the interface data, the method further comprises:
configuring the caching time of the interface data based on the change frequency of the interface data content corresponding to the interface needing to be requested in advance on the routing page;
and/or
After searching the interface data corresponding to the interface request from the cached interface data, the method further includes:
if the interface data corresponding to the interface request is not found from the cached interface data, sending the interface request to the server;
and receiving interface data returned by the server aiming at the interface request and applying the interface data to the routing page.
6. An interface data acquisition apparatus for a single-page application, comprising:
the sending module is suitable for sending an interface pre-request to a server side based on the pre-configured parameters required by the routing page interface corresponding to the routing script file when the routing script file is loaded;
the cache module is suitable for receiving interface data returned by the server aiming at the interface pre-request and caching the interface data;
the searching module is suitable for searching interface data corresponding to the interface request from the cached interface data if the mounting of the routing page is finished and the interface request is ready to be sent;
and the extracting module is suitable for extracting the searched interface data corresponding to the interface request and applying the extracted interface data to the routing page.
7. The apparatus of claim 6, wherein the caching module is further adapted to:
caching a pre-request state corresponding to the interface pre-request, wherein the pre-request state comprises pre-request completion or pre-request in-process.
8. The apparatus of claim 7, wherein the extraction module is further adapted to:
if the interface data corresponding to the interface request is found, analyzing whether the pre-request state corresponding to the cached interface pre-request is pre-request completion;
if the pre-request state is pre-request completion, extracting the found interface data corresponding to the interface request;
and if the pre-request state is not the pre-request completion, after waiting for the pre-request state to become the pre-request completion within a specified time, extracting the found interface data corresponding to the interface request.
9. The apparatus according to any one of claims 6 to 8,
the pre-configured parameters required by the routing page interface corresponding to the routing script file comprise:
at least one of the name of the routing page where the interface is located, the unique identifier of the interface and the path of the interface;
and/or
The lookup module is further adapted to: and searching interface data corresponding to the interface request from the cached interface data according to at least one of the unique interface identifier and the interface path of the request interface.
10. The apparatus according to any one of claims 6 to 8,
the device also comprises a configuration module which is suitable for configuring the cache time of the interface data based on the change frequency of the interface data content corresponding to the interface needing to be requested in advance on the routing page;
and/or
The device also comprises a receiving module; the sending module is further adapted to send the interface request to the server if the interface data corresponding to the interface request is not found from the cached interface data; the receiving module is suitable for receiving the interface data returned by the server aiming at the interface request and applying the interface data to the routing page.
11. A computer readable storage medium storing computer program code which, when run on a computing device, causes the computing device to execute the interface data acquisition method of a single-page application of any of claims 1 to 5.
12. A computing device, comprising: a processor; a memory storing computer program code; the computer program code, when executed by the processor, causes the computing device to perform the interface data acquisition method of a single-page application of any of claims 1-5.
CN201911414852.4A 2019-12-31 2019-12-31 Interface data acquisition method and device for single-page application and storage medium Pending CN111224880A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911414852.4A CN111224880A (en) 2019-12-31 2019-12-31 Interface data acquisition method and device for single-page application and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911414852.4A CN111224880A (en) 2019-12-31 2019-12-31 Interface data acquisition method and device for single-page application and storage medium

Publications (1)

Publication Number Publication Date
CN111224880A true CN111224880A (en) 2020-06-02

Family

ID=70828111

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911414852.4A Pending CN111224880A (en) 2019-12-31 2019-12-31 Interface data acquisition method and device for single-page application and storage medium

Country Status (1)

Country Link
CN (1) CN111224880A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111669321A (en) * 2020-06-11 2020-09-15 上海乾臻信息科技有限公司 Method, device and system for realizing routing request
CN111708600A (en) * 2020-08-20 2020-09-25 腾讯科技(深圳)有限公司 Page display method, device, equipment and computer readable storage medium
CN112231129A (en) * 2020-09-17 2021-01-15 北京健康之家科技有限公司 Data proxy service method, server, storage medium and computing equipment
CN112256342A (en) * 2020-09-22 2021-01-22 北京达佳互联信息技术有限公司 Page loading method and device and server
CN112925586A (en) * 2021-03-10 2021-06-08 深圳市活力天汇科技股份有限公司 Applet routing method, device, computer equipment and storage medium

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103353842A (en) * 2013-06-20 2013-10-16 北京小米科技有限责任公司 Webpage loading method and device
CN103530152A (en) * 2013-10-10 2014-01-22 小米科技有限责任公司 Method, device and terminal device for loading client-side scripts
CN104111836A (en) * 2014-07-14 2014-10-22 浪潮软件集团有限公司 Method for collecting and processing asynchronous loading data by network
CN105677708A (en) * 2015-12-28 2016-06-15 北京京东尚科信息技术有限公司 Data access method and apparatus
CN105760405A (en) * 2014-12-19 2016-07-13 阿里巴巴集团控股有限公司 Methods and devices for obtaining network resource for loading web page and method and device for caching network resource
CN106776784A (en) * 2016-11-24 2017-05-31 福建星网智慧科技股份有限公司 A kind of method that WEB page is quickly loaded
CN108228282A (en) * 2018-04-04 2018-06-29 北京三快在线科技有限公司 For the method and device of Website page loading
CN108563721A (en) * 2018-04-02 2018-09-21 杭州孚立计算机软件有限公司 A kind of framework for quickly loading webpage
US20180302492A1 (en) * 2013-09-25 2018-10-18 Akamai Technologies, Inc. Key resource prefetching using front-end optimization (FEO) configuration
CN110287432A (en) * 2019-06-28 2019-09-27 北京金山安全软件有限公司 Network information processing method and device and electronic equipment
CN110287433A (en) * 2019-06-28 2019-09-27 北京金山安全软件有限公司 Network information processing method and device and electronic equipment

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103353842A (en) * 2013-06-20 2013-10-16 北京小米科技有限责任公司 Webpage loading method and device
US20180302492A1 (en) * 2013-09-25 2018-10-18 Akamai Technologies, Inc. Key resource prefetching using front-end optimization (FEO) configuration
CN103530152A (en) * 2013-10-10 2014-01-22 小米科技有限责任公司 Method, device and terminal device for loading client-side scripts
CN104111836A (en) * 2014-07-14 2014-10-22 浪潮软件集团有限公司 Method for collecting and processing asynchronous loading data by network
CN105760405A (en) * 2014-12-19 2016-07-13 阿里巴巴集团控股有限公司 Methods and devices for obtaining network resource for loading web page and method and device for caching network resource
CN105677708A (en) * 2015-12-28 2016-06-15 北京京东尚科信息技术有限公司 Data access method and apparatus
CN106776784A (en) * 2016-11-24 2017-05-31 福建星网智慧科技股份有限公司 A kind of method that WEB page is quickly loaded
CN108563721A (en) * 2018-04-02 2018-09-21 杭州孚立计算机软件有限公司 A kind of framework for quickly loading webpage
CN108228282A (en) * 2018-04-04 2018-06-29 北京三快在线科技有限公司 For the method and device of Website page loading
CN110287432A (en) * 2019-06-28 2019-09-27 北京金山安全软件有限公司 Network information processing method and device and electronic equipment
CN110287433A (en) * 2019-06-28 2019-09-27 北京金山安全软件有限公司 Network information processing method and device and electronic equipment

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111669321A (en) * 2020-06-11 2020-09-15 上海乾臻信息科技有限公司 Method, device and system for realizing routing request
CN111708600A (en) * 2020-08-20 2020-09-25 腾讯科技(深圳)有限公司 Page display method, device, equipment and computer readable storage medium
CN112231129A (en) * 2020-09-17 2021-01-15 北京健康之家科技有限公司 Data proxy service method, server, storage medium and computing equipment
CN112231129B (en) * 2020-09-17 2023-12-26 北京水滴科技集团有限公司 Data proxy service method, server, storage medium and computing device
CN112256342A (en) * 2020-09-22 2021-01-22 北京达佳互联信息技术有限公司 Page loading method and device and server
CN112925586A (en) * 2021-03-10 2021-06-08 深圳市活力天汇科技股份有限公司 Applet routing method, device, computer equipment and storage medium
CN112925586B (en) * 2021-03-10 2024-02-27 深圳市活力天汇科技股份有限公司 Applet routing method, device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN111224880A (en) Interface data acquisition method and device for single-page application and storage medium
CN105095280B (en) Browser caching method and device
US10015226B2 (en) Methods for making AJAX web applications bookmarkable and crawlable and devices thereof
TWI670611B (en) Web file sending method, webpage rendering method and device, webpage rendering system
CN106911693B (en) Method and device for detecting hijacking of webpage content and terminal equipment
CN107766344B (en) Template rendering method and device and browser
CN107040584B (en) Method and device for downloading picture by client
CN108874922B (en) Client device, webpage rendering method based on single page application and storage medium
CN109428877B (en) Method and device for accessing service system through user equipment
WO2022048141A1 (en) Image processing method and apparatus, and computer readable storage medium
WO2018133772A1 (en) Method, device, storage medium, and electronic device for obtaining webpage resources
US20170359434A1 (en) Web caching with image and local storage
CN111880790A (en) Page rendering method, page rendering system, and computer-readable storage medium
CN111880788A (en) Page rendering method, device, client and computer readable storage medium
CN109446801B (en) Method, device, server and storage medium for detecting simulator access
CN106933817B (en) Content query method, device and system based on B/S structure
CN111310005A (en) Network request processing method and device, server and storage medium
CN113742551A (en) Dynamic data capture method based on script and puppeteer
CN108038150B (en) Webpage opening method and device and terminal equipment
US10095791B2 (en) Information search method and apparatus
US11115462B2 (en) Distributed system
CN111880789A (en) Page rendering method, device, server and computer-readable storage medium
CN109857966A (en) A kind of optimization method and browser of browser dynamically load web page resources
CN112565472B (en) Static resource processing method and device
CN110830537B (en) Page processing 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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200602