Page request processing method and device, electronic equipment and storage medium

文档序号:1963865 发布日期:2021-12-14 浏览:18次 中文

阅读说明:本技术 一种页面请求处理方法、装置、电子设备及存储介质 (Page request processing method and device, electronic equipment and storage medium ) 是由 刘文军 彭飞 邓竹立 于 2021-08-18 设计创作,主要内容包括:本发明提供了一种页面请求处理方法、装置、电子设备及存储介质。所述方法,包括:拦截针对目标应用中任一页面的页面加载请求,并检测页面加载请求的格式是否满足指定格式条件;如果页面加载请求满足指定格式条件,从本地读取与页面加载请求对应的缓存数据;如果在本地未读取到与页面加载请求携带的版本号一致,且对应于页面加载请求的缓存数据,发起针对页面的网络加载请求;接收针对网络加载请求返回的网络数据,根据网络数据加载页面,并将网络数据以及网络数据的版本号作为页面的缓存数据保存至本地;其中,指定格式条件包括页面加载请求中的统一资源定位符后添加有版本号参数,或者页面加载请求中的统一资源定位符满足内容分发网络的格式。(The invention provides a page request processing method and device, electronic equipment and a storage medium. The method comprises the following steps: intercepting a page loading request aiming at any page in a target application, and detecting whether the format of the page loading request meets a specified format condition; if the page loading request meets the specified format condition, reading cache data corresponding to the page loading request from the local; if the local cache data which is consistent with the version number carried by the page loading request and corresponds to the page loading request is not read, initiating a network loading request aiming at the page; receiving network data returned according to the network loading request, loading a page according to the network data, and saving the network data and the version number of the network data to the local as cache data of the page; the specified format condition comprises that a version number parameter is added after a uniform resource locator in the page loading request, or the uniform resource locator in the page loading request meets the format of the content distribution network.)

1. A page request processing method is characterized by comprising the following steps:

intercepting a page loading request aiming at any page in a target application, and detecting whether the format of the page loading request meets a specified format condition;

if the format of the page loading request meets the specified format condition, reading cache data corresponding to the page loading request from the local;

if the local cache data which is consistent with the version number carried by the page loading request and corresponds to the page loading request is not read, initiating a network loading request aiming at the page, wherein the network loading request is generated based on the page loading request;

receiving network data returned by aiming at the network loading request, loading the page according to the network data, and saving the network data and the version number of the network data to the local as cache data of the page;

the specified format condition comprises that a version number parameter is added after a uniform resource locator in the page loading request, or the uniform resource locator in the page loading request meets the format of a content distribution network.

2. The method of claim 1, further comprising:

and if the cache data corresponding to the page loading request is read locally and the version number of the cache data is consistent with the version number carried by the network request, returning the cache data to load the page.

3. The method according to claim 1, wherein the step of intercepting a page loading request for any page in a target application and detecting whether the format of the page loading request meets a specified format condition comprises:

under the condition that the page is a cache page needing to be preloaded, triggering a page loading request aiming at the cache page before the loading opportunity of the cache page;

intercepting the page loading request and detecting whether the format of the page loading request meets a specified format condition;

the step of receiving the network data returned by the network loading request, loading the page according to the network data, and saving the network data and the version number of the network data to the local as the cache data of the page includes:

and receiving network data returned according to the network loading request, and saving the network data and the version number of the network data to the local as cache data of the page.

4. The method according to claim 1 or 3, wherein the step of intercepting the page loading request and detecting whether the format of the page loading request meets a specified format condition comprises:

by initializing the modified configuration items during the target application, after webview sends out a page loading request, a first proxy method in a self-defined request management class is actively called to intercept the page loading request, and whether the format of the page loading request meets the specified format condition is detected by calling a second proxy method in the request management class;

the first proxy method is obtained by expanding a proxy method used for intercepting a picture request in a system where the target application is located, and the expansion mode of the proxy method comprises the following steps: by hooking and adjusting randLesURLScheme in WKWebView class: the method does not judge whether the page loading request is a picture request when the page loading request is intercepted.

5. The method of claim 1, wherein the target application comprises a mixed mode mobile application.

6. A page request processing apparatus, comprising:

the request intercepting module is used for intercepting a page loading request aiming at any page in a target application and detecting whether the format of the page loading request meets a specified format condition;

the local cache reading module is used for reading cache data corresponding to the page loading request from the local if the format of the page loading request meets the specified format condition;

a request sending module, configured to initiate a network loading request for the page if the local cache data is not read locally, where the local cache data is consistent with a version number carried in the page loading request and corresponds to the page loading request, and the network loading request is generated based on the page loading request;

the data cache module is used for receiving the network data returned by the network loading request, loading the page according to the network data, and saving the network data and the version number of the network data to the local as cache data of the page;

the specified format condition comprises that a version number parameter is added after a uniform resource locator in the page loading request, or the uniform resource locator in the page loading request meets the format of a content distribution network.

7. The apparatus of claim 6, further comprising:

and the cache data using module is used for returning the cache data to load the page if the cache data corresponding to the page loading request is read locally and the version number of the cache data is consistent with the version number carried by the network request.

8. The apparatus of claim 6, wherein the request intercepting module comprises:

the request triggering submodule is used for triggering a page loading request aiming at the cache page before the loading opportunity of the cache page under the condition that the page is the cache page needing to be preloaded;

the request intercepting submodule intercepts the page loading request and detects whether the format of the page loading request meets a specified format condition;

the data caching module is specifically configured to:

and receiving network data returned according to the network loading request, and saving the network data and the version number of the network data to the local as cache data of the page.

9. The apparatus according to claim 6 or 8, wherein the request intercepting module is specifically configured to:

by initializing the modified configuration items during the target application, after webview sends out a page loading request, a first proxy method in a self-defined request management class is actively called to intercept the page loading request, and whether the format of the page loading request meets the specified format condition is detected by calling a second proxy method in the request management class;

the first proxy method is obtained by expanding a proxy method used for intercepting a picture request in a system where the target application is located, and the expansion mode of the proxy method comprises the following steps: by hooking and adjusting randLesURLScheme in WKWebView class: the method does not judge whether the page loading request is a picture request when the page loading request is intercepted.

10. The apparatus of claim 6, wherein the target application comprises a mixed mode mobile application.

11. An electronic device, comprising: processor, memory and a computer program stored on the memory and executable on the processor, which computer program, when executed by the processor, carries out the steps of the page request processing method according to any of claims 1 to 5.

12. A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, which computer program, when being executed by a processor, carries out the steps of the page request processing method according to any one of claims 1 to 5.

Technical Field

The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for processing a page request, an electronic device, and a storage medium.

Background

With the popularization of electronic devices such as smartphones, Application (App) based on the electronic devices is involved in various industries. Moreover, App development is continuously developing into new fields, and innovations in each aspect can cause a booming of App development regardless of App application objects and App development methods. Recently, there has been a new proposal about App development, that is, Hybrid App (mixed mode mobile application) development. The Hybrid App can haveAdvantage of Native App (Native application) good user interaction experienceAndweb App (Web application) advantage of cross-platform development ".

In Hybrid APP, most web pages (web pages) do not need to be updated in real time, and in consideration of consumption of network traffic and speed of loading and displaying, data interaction with a server is less, so that user experience is better. Therefore, a cache mechanism is required, which not only can greatly relieve the pressure of data interaction, but also can make offline browsing possible. When a web page in the Hybrid App loads a certain URL (Uniform Resource Locator) by using a system control self-contained cache mechanism, network data is saved as a temporary cache, and when the control is opened at this time, the same URL is loaded, the temporary cache is used.

However, since the cache of the web page is a temporary cache, when the webview (web page view) is released or a certain period of time elapses, the cache is not available, which results in that the network request needs to be sent again when the web page is loaded next time, thereby causing waste of traffic and also affecting the loading efficiency of the page.

Disclosure of Invention

The embodiment of the invention provides a page request processing method and device, electronic equipment and a storage medium, and aims to solve the problems that flow is easy to waste in a page loading process and loading efficiency is poor.

In order to solve the technical problem, the invention is realized as follows:

in a first aspect, an embodiment of the present invention provides a page request processing method, including:

intercepting a page loading request aiming at any page in a target application, and detecting whether the format of the page loading request meets a specified format condition;

if the format of the page loading request meets the specified format condition, reading cache data corresponding to the page loading request from the local;

if the local cache data which is consistent with the version number carried by the page loading request and corresponds to the page loading request is not read, initiating a network loading request aiming at the page, wherein the network loading request is generated based on the page loading request;

receiving network data returned by aiming at the network loading request, loading the page according to the network data, and saving the network data and the version number of the network data to the local as cache data of the page;

the specified format condition comprises that a version number parameter is added after a uniform resource locator in the page loading request, or the uniform resource locator in the page loading request meets the format of a content distribution network.

Optionally, the method further comprises:

and if the cache data corresponding to the page loading request is read locally and the version number of the cache data is consistent with the version number carried by the network request, returning the cache data to load the page.

Optionally, the step of intercepting a page loading request for any page in a target application and detecting whether a format of the page loading request meets a specified format condition includes:

under the condition that the page is a cache page needing to be preloaded, triggering a page loading request aiming at the cache page before the loading opportunity of the cache page;

intercepting the page loading request and detecting whether the format of the page loading request meets a specified format condition;

the step of receiving the network data returned by the network loading request, loading the page according to the network data, and saving the network data and the version number of the network data to the local as the cache data of the page includes:

and receiving network data returned according to the network loading request, and saving the network data and the version number of the network data to the local as cache data of the page.

Optionally, the step of intercepting the page loading request and detecting whether a format of the page loading request meets a specified format condition includes:

by initializing the modified configuration items during the target application, after webview sends out a page loading request, a first proxy method in a self-defined request management class is actively called to intercept the page loading request, and whether the format of the page loading request meets the specified format condition is detected by calling a second proxy method in the request management class;

the first proxy method is obtained by expanding a proxy method used for intercepting a picture request in a system where the target application is located, and the expansion mode of the proxy method comprises the following steps: by hooking and adjusting randLesURLScheme in WKWebView class: the method does not judge whether the page loading request is a picture request when the page loading request is intercepted.

Optionally, the target application comprises a mixed mode mobile application.

In a second aspect, an embodiment of the present invention provides a page request processing apparatus, including:

the request intercepting module is used for intercepting a page loading request aiming at any page in a target application and detecting whether the format of the page loading request meets a specified format condition;

the local cache reading module is used for reading cache data corresponding to the page loading request from the local if the format of the page loading request meets the specified format condition;

a request sending module, configured to initiate a network loading request for the page if the local cache data is not read locally, where the local cache data is consistent with a version number carried in the page loading request and corresponds to the page loading request, and the network loading request is generated based on the page loading request;

the data cache module is used for receiving the network data returned by the network loading request, loading the page according to the network data, and saving the network data and the version number of the network data to the local as cache data of the page;

the specified format condition comprises that a version number parameter is added after a uniform resource locator in the page loading request, or the uniform resource locator in the page loading request meets the format of a content distribution network.

Optionally, the apparatus further comprises:

and the cache data using module is used for returning the cache data to load the page if the cache data corresponding to the page loading request is read locally and the version number of the cache data is consistent with the version number carried by the network request.

Optionally, the request intercepting module includes:

the request triggering submodule is used for triggering a page loading request aiming at the cache page before the loading opportunity of the cache page under the condition that the page is the cache page needing to be preloaded;

the request intercepting submodule intercepts the page loading request and detects whether the format of the page loading request meets a specified format condition;

the data caching module is specifically configured to:

and receiving network data returned according to the network loading request, and saving the network data and the version number of the network data to the local as cache data of the page.

Optionally, the request intercepting module is specifically configured to:

by initializing the modified configuration items during the target application, after webview sends out a page loading request, a first proxy method in a self-defined request management class is actively called to intercept the page loading request, and whether the format of the page loading request meets the specified format condition is detected by calling a second proxy method in the request management class;

the first proxy method is obtained by expanding a proxy method used for intercepting a picture request in a system where the target application is located, and the expansion mode of the proxy method comprises the following steps: by hooking and adjusting randLesURLScheme in WKWebView class: the method does not judge whether the page loading request is a picture request when the page loading request is intercepted.

Optionally, the target application comprises a mixed mode mobile application.

In a third aspect, an embodiment of the present invention additionally provides an electronic device, including: memory, a processor and a computer program stored on the memory and executable on the processor, the computer program, when executed by the processor, implementing the steps of the page request processing method according to the first aspect.

In a fourth aspect, the embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when executed by a processor, the computer program implements the steps of the page request processing method according to the first aspect.

In the embodiment of the invention, the network data of the webpage loading request meeting the specified format condition is completely stored in the local disk by intercepting the webpage loading request, so that a preloading scheme based on a carrier cache is realized. The method saves the flow for the user, improves the fluency of the page, realizes off-line browsing, and greatly improves the usability of the App.

Drawings

FIG. 1 is a flowchart illustrating steps of a method for processing a page request according to an embodiment of the present invention;

FIG. 2 is a flowchart illustrating steps of another method for processing a page request according to an embodiment of the present invention;

fig. 3 is a schematic structural diagram of a page request processing apparatus in an embodiment of the present invention;

fig. 4 is a schematic structural diagram of another page request processing apparatus in the embodiment of the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

Referring to fig. 1, a flowchart illustrating steps of a page request processing method according to an embodiment of the present invention is shown.

Step 110, intercepting a page loading request aiming at any page in a target application, and detecting whether the format of the page loading request meets a specified format condition;

step 120, if the format of the page loading request meets the specified format condition, reading the cache data corresponding to the page loading request from the local; the specified format condition comprises that a version number parameter is added after a uniform resource locator in the page loading request, or the uniform resource locator in the page loading request meets the format of a content distribution network.

Step 130, if the local cache data is not read to be consistent with the version number carried by the page loading request and corresponds to the page loading request, initiating a network loading request for the page, wherein the network loading request is generated based on the page loading request.

Step 140, receiving the network data returned by the network loading request, loading the page according to the network data, and saving the network data and the version number of the network data as cache data of the page to the local.

In the embodiment of the invention, the response data of the page loading request meeting the specified format condition in the page in the target App is stored in the local disk by intercepting the webview page loading request, so that the resource preloading is realized, and under the condition of repeatedly accessing the same page, the network loading request does not need to be sent again to obtain the related data again, and the page quick loading can be directly realized based on the local cache data.

Specifically, when a user triggers a page loading request for a certain page in a target application through a client, in order to avoid traffic waste, the page loading request may be intercepted to determine whether a format of the page loading request meets a specified format condition.

In the embodiment of the invention, if local caching is carried out on all types of requests, the occupation of local storage space is more easily caused, and the system performance is influenced. Therefore, in the embodiment of the present invention, in order to balance the system performance and the page loading efficiency, not all requests are intercepted and local cache is performed, but the local cache is only required to be performed when the page loading request satisfies any one of the following two specified format conditions:

firstly, in a standard mode, a version number parameter is added after a Uniform Resource Locator (URL) in a page loading request, namely, a cachevers parameter, for example, http:// xxx/xxxcacherver ═ xx is a URL meeting the condition;

cdn (Content Delivery Network), the format of URL meeting cdn in the page load request will also be cached, for example, http:// xxx/xxx _ v version number. xx is a URL meeting the condition, which contains version number information.

The version number can be understood as a version number adapted to the page of the request, and in order to ensure the page loading effect, the page needs to be loaded through network data of a corresponding version number.

In addition, in the embodiment of the present invention, the page loading request may be intercepted in any available manner, which is not limited to this embodiment of the present invention.

For a page loading request meeting a specified format condition, network data corresponding to the page loading request may have been cached locally before, so to avoid repeated caching, cache data corresponding to the page loading request may be read locally, if the version number carried by the page loading request meeting the specified format condition is not locally read, and the cache data corresponding to the page loading request, that is, the page loading request cannot locally read the cache data corresponding to the page loading request, or the cache data corresponding to the page loading request can be locally read, but the version number of the read cache data is not consistent with the version number carried by the page loading request, a network loading request for a corresponding page needs to be initiated to request to acquire the network data required by loading the page, where the network loading request is generated based on the page loading request, for example, the network load request may include the same URL in the corresponding page load request, and so on. The page loading request can be sent to the server of the corresponding target application by the client, and in order to respond to the page loading request, the server can return the corresponding network data to load the rendering page.

For the client, when receiving the network data returned according to the network loading request, loading the page according to the network data, and saving the network data and the version number of the network data to the local as cache data of the page, that is, the client can actively initiate the network loading request of the corresponding URL at this time, after requesting the return data, the returned network data can be updated to the local, and at the same time, the version number of the network data of the latest version needs to be recorded, and the corresponding network data can be returned to the webview for use while updating the cache data and the version number, so as to load and display the corresponding page at the client.

Referring to fig. 2, in the embodiment of the present invention, the method may further include:

and 150, if the cache data corresponding to the page loading request is read locally and the version number of the cache data is consistent with the version number carried by the network request, returning the cache data to load the page.

In the embodiment of the invention, when the cache data corresponding to the page loading request meeting the specified format condition is read locally, the cache data adapted to the page loading request can be searched locally, and further the version number judgment is performed, that is, if the request meeting the specified format condition can read the cache data locally, the version number judgment is performed first, whether the version number carried by the page loading request is consistent with the version number of the cache data is compared, and if the version number is consistent, the corresponding cache data can be directly returned to any page display tools such as webview and the like, so as to render the corresponding page.

In addition, for the page loading request meeting the specified format condition, if cache data corresponding to the page loading request is not read from the local, the network loading request of the page loading request can be directly and actively initiated, and the data to be requested to be returned is stored and is returned to the webview display page for use.

For the page loading request that does not meet the specified format condition, the page loading request is directly sent out, but a system default temporary caching mechanism (for example, a static resource file with a code of 200 (i.e., indicating that the request is successful) is cached, but the validity period of the caching mechanism is controlled by the system) is set for the page loading request, so that some static resource files in the requests can also go through the system default temporary caching mechanism, which is not limited in the embodiment of the present invention.

Optionally, in an embodiment of the present invention, the step 110 may further include:

step 111, under the condition that the page is a cache page needing to be preloaded, triggering a page loading request aiming at the cache page before the loading opportunity of the cache page;

step 112, intercepting the page loading request, and detecting whether the format of the page loading request meets a specified format condition.

Generally, a user may actively trigger a page load request for a page in a target application, and most pages in the target application may trigger loading at any time. In addition, in practical applications, there may be some pages in the application that are visible only at a specified time (i.e., at a specified loading opportunity), for example, an active page that is set for pre-heating of a specified active holiday, and in general, the active page is visible only at its corresponding active holiday and is not visible before. For such pages, in order to ensure that the corresponding page can be quickly loaded when the user accesses the relevant page during the specified activity day, the network data corresponding to the corresponding page can be preloaded before the specified loading opportunity. For a cache page needing to be preloaded in a target application, the cache page is invisible before the loading opportunity, so that a user can hardly actively trigger a page loading request for the corresponding cache page before the loading opportunity.

Therefore, in the embodiment of the invention, before the loading time of the cache page, an invisible cache page, that is, a cache page needing to be preloaded, is triggered in advance by some trigger time in the App (for example, based on interaction between a web page and a Native, a page url needing to be preloaded is actively triggered and transmitted to the Native by the web page), so as to perform a related page loading request, further intercept the corresponding page loading request, and detect whether the format of the page loading request meets a specified format condition (wherein, a request meeting the specified format condition will go to a local cache mechanism to cache resources), thereby achieving the purpose of resource preloading, and thus, a cache can be used when a page which is successfully preloaded is opened for the first time.

In addition, in the embodiment of the present invention, for the local preloading mechanism, a corresponding validity period may also be set, and different validity periods may be set for different types of network data, which is not limited in the embodiment of the present invention. As described above, when the version number of the network data in the local cache is not consistent with the version number of the page loading request, the network data in the corresponding local cache may be deleted, or when it is detected that the version number of the page is updated, the network data in the local cache corresponding to the version number of the page may be deleted, or for a cached page, after the loading opportunity ends, the network data in the local cache corresponding to the version number of the page may be deleted.

For other non-cached pages, the loading frequency of each page in each specified time period can be detected, if the current loading frequency of a certain page is lower than a specified frequency threshold, the locally cached network data corresponding to the certain page can be deleted, and the like.

Accordingly, the step 140 may further include: and receiving network data returned according to the network loading request, and saving the network data and the version number of the network data to the local as cache data of the page.

For a cache page with a loading opportunity, network data of the cache page is generally preloaded before the loading opportunity of the cache page, so that the corresponding cache page does not need to be loaded at this time. That is, for the cache page, when preloading the network data thereof, after receiving the network data returned in response to the network loading request, the front end does not need to be returned for page rendering and loading, and only the version number of the network data and the version number of the network data thereof need to be saved locally as the cache data of the cache page.

After the subsequent loading opportunity of the cache page comes, when a user triggers to access a related page or related operation which has interaction with the cache page (for example, an active page is the cache page and is displayed when a target application is started, then in the loading opportunity of the active page, if the user triggers to start the target application, a page loading request for the cache page may be automatically triggered), the network data of the cache page may be directly obtained from the local and the cache page is loaded.

Optionally, in an embodiment of the present invention, the target application includes Hybrid App (mixed mode mobile application).

Optionally, in the embodiment of the present invention, the process of intercepting the page loading request and detecting whether the format of the page loading request meets the specified format condition may specifically include:

by initializing the modified configuration items during the target application, after webview sends out a page loading request, a first proxy method in a self-defined request management class is actively called to intercept the page loading request, and whether the format of the page loading request meets the specified format condition is detected by calling a second proxy method in the request management class;

the first proxy method is obtained by expanding a proxy method used for intercepting a picture request in a system where the target application is located, and the expansion mode of the proxy method comprises the following steps: by hooking and adjusting randLesURLScheme in WKWebView class: the method does not judge whether the page loading request is a picture request when the page loading request is intercepted.

The Hybrid App is an App between a Web-App and a Native-App (Native application), and has the advantages of a Native App in good user interaction experience and the advantages of a Web App in cross-platform development. Native in Hybrid APP provides a container (such as WKWebview), Html & Css & JS is used for service development, and rapid iteration of services is realized through dynamic update.

In the embodiment of the invention, in order to accurately intercept the page loading request triggered by the user, the configuration item can be modified when the webview is initialized, so that the webview can support interception of http(s) requests (namely all page loading requests) sent by the webview to perform custom processing, and the custom-created management class is introduced to process the page loading request sent by the webview.

Then, when the webview sends out a page loading request, the webview actively calls a related proxy method in the corresponding custom-created management class, and the filtering and custom-defining processing of the page loading request can be performed in the related proxy method.

Specifically, when initializing webview, configuration items provided by the system may be modified, so that all http(s) requests issued by webview may be intercepted, for example, a specific manner for modifying configuration items may be as shown in the following code segment:

the WBWKURLSchemeHandler is a self-defined request management class, and after the web view sends out the page loading request, related proxy methods in the request management class are actively called to intercept all the page loading requests.

In practical application, the agent method for specifically intercepting the request is provided by the system, but the default of the system can only support the request for intercepting the downloaded picture, that is, the picture request, so in the embodiment of the present invention, in order to intercept all the requests, the agent method can be expanded to intercept all http(s) network requests, and the expansion means uses a policy for modifying the system method, specifically, the agent method can be implemented by hooking (hook) and adjusting handlesourchechem in wwebview: the method replaces the WBWKHandlesURLScheme with the expanded WBWKHandlesURLScheme: the method ensures that whether the page loading request is a picture request is not judged when the page loading request is intercepted. For example, the implementation code of the first proxy method may be as follows:

in addition, the logic of judging the format condition of the page loading request, generating and sending the network loading request and the like can be realized by the second proxy method. In embodiments of the present invention, the second proxy method may be constructed in any available manner, and the embodiments of the present invention are not limited thereto.

For example, the following proxy methods are declared in the system: - (void) webView (wkvewview:) webView starturlschemestask (id < wkurlschemestask >) urlschemestask, but a specific implementation logic of the method is not defined, so in the embodiment of the present invention, the implementation logic of the method may be constructed based on the processing manner of the intercepted web page loading request in the embodiment of the present invention, so as to obtain the second proxy method.

Then, once the web page load request is intercepted, each web page load request sent through webview goes through the second proxy method. The second proxy method can judge whether the webpage loading request is in a format condition specified by the symbol, and respectively execute corresponding subsequent operations under the conditions of conformity and nonconformity.

In the embodiment of the invention, network data of the webpage loading request meeting the specified format condition in the web page in the Hybrid App are all stored in the local disk by intercepting the webview webpage loading request, and the invisible cache page is triggered in advance to perform resource preloading, so that a Web carrier cache preloading scheme based on the Hybird App is realized. The method saves the flow for the user, improves the fluency of the page, realizes off-line browsing, and greatly improves the usability of the App.

Referring to fig. 3, a schematic structural diagram of a page request processing apparatus in an embodiment of the present invention is shown.

The page request processing device of the embodiment of the invention comprises: a request interception module 210, a local cache reading module 220, a request issuing module 230, and a data caching module 240.

The functions of the modules and the interaction relationship between the modules are described in detail below.

A request intercepting module 210, configured to intercept a page loading request for any page in a target application, and detect whether a format of the page loading request meets a specified format condition;

a local cache reading module 220, configured to, if the format of the page loading request meets a specified format condition, locally read cache data corresponding to the page loading request;

a request issuing module 230, configured to initiate a network loading request for the page if the local cache data is not read locally, where the local cache data is consistent with the version number carried in the page loading request and corresponds to the page loading request, and the network loading request is generated based on the page loading request;

a data caching module 240, configured to receive network data returned in response to the network loading request, load the page according to the network data, and store the network data and a version number of the network data as cache data of the page to a local location;

the specified format condition comprises that a version number parameter is added after a uniform resource locator in the page loading request, or the uniform resource locator in the page loading request meets the format of a content distribution network.

Referring to fig. 4, in an embodiment of the present invention, the apparatus may further include:

and a cache data using module 250, configured to, if the cache data corresponding to the page loading request is read locally and the version number of the cache data is consistent with the version number carried by the network request, return the cache data to load the page.

Optionally, in this embodiment of the present invention, the request intercepting module 210 further includes:

the request triggering submodule is used for triggering a page loading request aiming at the cache page before the loading opportunity of the cache page under the condition that the page is the cache page needing to be preloaded;

the request intercepting submodule intercepts the page loading request and detects whether the format of the page loading request meets a specified format condition;

accordingly, the data caching module may be specifically configured to:

and receiving network data returned according to the network loading request, and saving the network data and the version number of the network data to the local as cache data of the page.

Optionally, in this embodiment of the present invention, the request intercepting module may be specifically configured to:

by initializing the modified configuration items during the target application, after webview sends out a page loading request, a first proxy method in a self-defined request management class is actively called to intercept the page loading request, and whether the format of the page loading request meets the specified format condition is detected by calling a second proxy method in the request management class;

the first proxy method is obtained by expanding a proxy method used for intercepting a picture request in a system where the target application is located, and the expansion mode of the proxy method comprises the following steps: by hooking and adjusting randLesURLScheme in WKWebView class: the method does not judge whether the page loading request is a picture request when the page loading request is intercepted.

Optionally, in this embodiment of the present invention, the target application includes a mixed-mode mobile application.

Preferably, an embodiment of the present invention further provides an electronic device, including: the processor, the memory, and the computer program stored in the memory and capable of running on the processor, when executed by the processor, implement each process of the above-mentioned page request processing method embodiment, and can achieve the same technical effect, and are not described herein again to avoid repetition.

The embodiment of the present invention further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when being executed by a processor, the computer program implements each process of the above-mentioned page request processing method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here. The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.

It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.

Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.

While the present invention has been described with reference to the embodiments shown in the drawings, the present invention is not limited to the embodiments, which are illustrative and not restrictive, and it will be apparent to those skilled in the art that various changes and modifications can be made therein without departing from the spirit and scope of the invention as defined in the appended claims.

Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.

It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.

In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.

The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.

The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a U disk, a removable hard disk, a ROM, a RAM, a magnetic disk, or an optical disk.

The above description is only for the specific embodiments of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present invention, and all the changes or substitutions should be covered within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

16页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种基于模板的路网运行监测方法、装置、设备及介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!