CN111966937A - Search response method and device and computer readable storage medium - Google Patents
Search response method and device and computer readable storage medium Download PDFInfo
- Publication number
- CN111966937A CN111966937A CN202010920889.0A CN202010920889A CN111966937A CN 111966937 A CN111966937 A CN 111966937A CN 202010920889 A CN202010920889 A CN 202010920889A CN 111966937 A CN111966937 A CN 111966937A
- Authority
- CN
- China
- Prior art keywords
- resource
- offline
- resource package
- search
- package
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/95—Retrieval from the web
- G06F16/957—Browsing optimisation, e.g. caching or content distillation
- G06F16/9574—Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/60—Software deployment
- G06F8/65—Updates
- G06F8/658—Incremental updates; Differential updates
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Information Transfer Between Computers (AREA)
Abstract
本申请提供了一种搜索响应方法、装置及计算机可读存储介质,该搜索响应方法包括:在接收到资源搜索请求时,确定当前的网络连接状态;在网络连接状态为网络连接异常状态时,获取本地缓存的离线资源包;基于离线资源包输出对应于资源搜索请求的搜索结果页面。通过本申请方案的实施,在本地缓存有离线资源包,若网络连接异常时,直接根据离线资源包对用户的资源搜索请求进行响应,有效提高了页面加载速度,并保证了页面加载的成功率。
The present application provides a search response method, device and computer-readable storage medium. The search response method includes: when a resource search request is received, determining a current network connection state; when the network connection state is an abnormal network connection state, Obtain the locally cached offline resource pack; output the search result page corresponding to the resource search request based on the offline resource pack. Through the implementation of the solution of the present application, the offline resource package is cached locally. If the network connection is abnormal, the user's resource search request is directly responded to according to the offline resource package, which effectively improves the page loading speed and ensures the success rate of page loading. .
Description
技术领域technical field
本申请涉及电子技术领域,尤其涉及一种搜索响应方法、装置及计算机可读存储介质。The present application relates to the field of electronic technologies, and in particular, to a search response method, apparatus, and computer-readable storage medium.
背景技术Background technique
随着终端技术的快速发展,手机、平板电脑等电子装置在用户的工作和生活中使用频率越来越高,用户通常会使用电子装置上所安装的浏览器客户端进行资源搜索,当浏览器客户端接收到用户的资源搜索请求时,浏览器客户端提供页面来呈现所需展示的内容。With the rapid development of terminal technology, electronic devices such as mobile phones and tablet computers are used more and more frequently in users' work and life. Users usually use the browser client installed on the electronic device to search for resources. When the client receives the user's resource search request, the browser client provides a page to present the content to be displayed.
目前,当每次用户发起资源搜索请求时,浏览器客户端均需要访问服务器来获取对应资源,从而对网络的依赖程度较大,倘若网络环境不好或断网时,会出现页面加载较慢或加载出错的问题。At present, every time a user initiates a resource search request, the browser client needs to access the server to obtain the corresponding resource, which is highly dependent on the network. If the network environment is not good or the network is disconnected, the page loading will be slow. or loading errors.
发明内容SUMMARY OF THE INVENTION
本申请实施例提供了一种搜索响应方法、装置及计算机可读存储介质,至少能够解决相关技术中浏览器客户端在网络环境不好或断网时,容易导致页面加载较慢或加载出错的问题。The embodiments of the present application provide a search response method, device, and computer-readable storage medium, which can at least solve the problem that the browser client in the related art is prone to slow page loading or loading errors when the network environment is not good or the network is disconnected. question.
本申请实施例第一方面提供了一种搜索响应方法,应用于浏览器客户端,包括:A first aspect of the embodiments of the present application provides a search response method, which is applied to a browser client, including:
在接收到资源搜索请求时,确定当前的网络连接状态;When receiving a resource search request, determine the current network connection state;
在所述网络连接状态为网络连接异常状态时,获取本地缓存的离线资源包;When the network connection state is an abnormal state of the network connection, obtain a locally cached offline resource package;
基于所述离线资源包输出对应于所述资源搜索请求的搜索结果页面。A search result page corresponding to the resource search request is output based on the offline resource bundle.
本申请实施例第二方面提供了一种搜索响应装置,应用于浏览器客户端,包括:A second aspect of the embodiments of the present application provides a search response device, which is applied to a browser client, including:
确定模块,用于在接收到资源搜索请求时,确定当前的网络连接状态;A determination module, used to determine the current network connection state when a resource search request is received;
获取模块,用于在所述网络连接状态为网络连接异常状态时,获取本地缓存的离线资源包;an acquisition module, configured to acquire a locally cached offline resource package when the network connection state is an abnormal state of the network connection;
输出模块,用于基于所述离线资源包输出对应于所述资源搜索请求的搜索结果页面。An output module, configured to output a search result page corresponding to the resource search request based on the offline resource package.
本申请实施例第三方面提供了一种电子装置,包括:存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,处理器执行计算机程序时,实现上述本申请实施例第一方面提供的搜索响应方法中的各步骤。A third aspect of the embodiments of the present application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the computer program, the above-mentioned first embodiment of the present application is implemented. Steps in the search response method provided in an aspect.
本申请实施例第四方面提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时,实现上述本申请实施例第一方面提供的搜索响应方法中的各步骤。A fourth aspect of the embodiments of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, implements the steps in the search response method provided in the first aspect of the embodiments of the present application. .
由上可见,根据本申请方案所提供的搜索响应方法、装置及计算机可读存储介质,在接收到资源搜索请求时,确定当前的网络连接状态;在网络连接状态为网络连接异常状态时,获取本地缓存的离线资源包;基于离线资源包输出对应于资源搜索请求的搜索结果页面。通过本申请方案的实施,在本地缓存有离线资源包,若网络连接异常时,直接根据离线资源包对用户的资源搜索请求进行响应,有效提高了页面加载速度,并保证了页面加载的成功率。As can be seen from the above, according to the search response method, device and computer-readable storage medium provided by the solution of the present application, when a resource search request is received, the current network connection state is determined; when the network connection state is an abnormal state of network connection, the Locally cached offline resource pack; output the search result page corresponding to the resource search request based on the offline resource pack. Through the implementation of the solution of the present application, the offline resource package is cached locally. If the network connection is abnormal, the user's resource search request is directly responded to the offline resource package, which effectively improves the page loading speed and ensures the success rate of page loading. .
附图说明Description of drawings
图1为本申请第一实施例提供的搜索响应方法的基本流程示意图;FIG. 1 is a schematic flowchart of a basic flow of a search response method provided by the first embodiment of the present application;
图2为本申请第一实施例提供的一种搜索响应界面的示意图;2 is a schematic diagram of a search response interface provided by the first embodiment of the present application;
图3为本申请第一实施例提供的一种离线资源包更新方法的流程示意图;3 is a schematic flowchart of an offline resource package update method provided by the first embodiment of the present application;
图4为本申请第一实施例提供的另一种离线资源包更新方法的流程示意图;4 is a schematic flowchart of another offline resource package update method provided by the first embodiment of the present application;
图5为本申请第二实施例提供的搜索响应方法的细化流程示意图;FIG. 5 is a schematic flowchart of a refinement of the search response method provided by the second embodiment of the present application;
图6为本申请第三实施例提供的一种搜索响应装置的程序模块示意图;FIG. 6 is a schematic diagram of program modules of a search response apparatus provided by the third embodiment of the present application;
图7为本申请第三实施例提供的另一种搜索响应装置的程序模块示意图;FIG. 7 is a schematic diagram of program modules of another search response apparatus provided by the third embodiment of the present application;
图8为本申请第四实施例提供的电子装置的结构示意图。FIG. 8 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present application.
具体实施方式Detailed ways
为使得本申请的发明目的、特征、优点能够更加的明显和易懂,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而非全部实施例。基于本申请中的实施例,本领域技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, features and advantages of the invention of the present application more obvious and understandable, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. The embodiments described above are only a part of the embodiments of the present application, but not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of this application.
为了解决相关技术中浏览器客户端在网络环境不好或断网时,容易导致页面加载较慢或加载出错的缺陷,本申请第一实施例提供了一种搜索响应方法,应用于浏览器客户端,如图1为本实施例提供的搜索响应方法的基本流程图,该搜索响应方法包括以下的步骤:In order to solve the defect in the related art that when the network environment of the browser client is not good or the network is disconnected, it is easy to cause slow page loading or loading errors, the first embodiment of the present application provides a search response method, which is applied to the browser client terminal, as shown in FIG. 1 , the basic flowchart of the search response method provided by the present embodiment, the search response method includes the following steps:
步骤101、在接收到资源搜索请求时,确定当前的网络连接状态。Step 101: When a resource search request is received, determine the current network connection state.
具体的,本实施例的搜索响应方法可以应用于搜索直达场景,也即当客户端检测到用户在浏览器搜索框输入的字符时,生成资源搜索请求,也可以应用于普通搜索场景,也即当用户在浏览器搜索框输入字符之后,触发搜索控件生成资源搜索请求。Specifically, the search response method in this embodiment can be applied to a direct search scenario, that is, when the client detects the characters entered by the user in the browser search box, and generates a resource search request, it can also be applied to a common search scenario, that is After the user enters characters in the browser search box, the search control is triggered to generate a resource search request.
应当说明的是,本实施例的网络连接状态可以包括网络连接正常状态和网络连接异常状态,进一步地,网络连接异常状态可以包括网络连接断开状态以及低质量网络连接状态。It should be noted that the network connection state in this embodiment may include a normal network connection state and an abnormal network connection state, and further, the abnormal network connection state may include a disconnected network connection state and a low-quality network connection state.
步骤102、在网络连接状态为网络连接异常状态时,获取本地缓存的离线资源包。Step 102: When the network connection state is an abnormal network connection state, obtain a locally cached offline resource package.
具体的,在本实施例中,在客户端本地缓存有html5页面的资源包,该资源包内可以包括html,css,js,jpg文件等。应当理解的是,本实施例的离线资源包可以是在网络连接正常状态下从服务端所获取的资源包,离线资源包用于客户端在离线状态下加载页面。Specifically, in this embodiment, a resource package of an html5 page is cached locally on the client side, and the resource package may include html, css, js, jpg files, and the like. It should be understood that the offline resource package in this embodiment may be a resource package obtained from the server in a normal network connection state, and the offline resource package is used by the client to load a page in an offline state.
在本实施例的一些实施方式中,获取本地缓存的离线资源包包括:获取输入资源搜索请求的用户的搜索响应需求;基于搜索响应需求从本地缓存的多个离线资源包中,获取对应的离线资源包。In some implementations of this embodiment, acquiring a locally cached offline resource package includes: acquiring a search response requirement of a user who inputs a resource search request; acquiring a corresponding offline resource package from a plurality of locally cached offline resource packages based on the search response requirement resource pack.
具体的,本实施例的搜索响应需求可以关联于用户以期响应的搜索结果页面中的资源类型。在本实施例中,可以在本地缓存多种不同版本的离线资源包,各版本的离线资源包内所包括的资源类型有所不同,用以满足不同用户的搜索需求。例如本实施例考虑到不同用户的对搜索结果的接受程度有所不同,部分用户较为追求搜索结果的全面性,那么离线资源包可以为包括词条、新闻、音频、视频、图片等多类型资源的资源包,而部分用户较为追求搜索结果的洁净性,那么离线资源包可以为仅包括词条和新闻的资源包。Specifically, the search response requirement in this embodiment may be associated with the resource type in the search result page that the user expects to respond to. In this embodiment, a variety of offline resource packs of different versions may be cached locally, and the types of resources included in the offline resource packs of each version are different, so as to meet the search requirements of different users. For example, in this embodiment, considering that different users have different degrees of acceptance of search results, and some users pursue the comprehensiveness of search results, the offline resource package may include multiple types of resources including entries, news, audio, video, and pictures. However, some users are more interested in the cleanliness of search results, so the offline resource package can be a resource package that only includes entries and news.
步骤103、基于离线资源包输出对应于资源搜索请求的搜索结果页面。
如图2所示为本实施例提供的一种搜索响应界面的示意图,具体的,本实施例在识别用户在浏览器搜索框输入的关键词之后(例如图2中周杰伦),客户端将该关键词输入到网页视图Webview中的JavaScript接口,然后通知到WebView,WebView里面一些js脚本直接请求调用离线资源包,从中获取页面展示所需的html、css、js、resource文件等(如图2中搜索框下方的下载卡片、新闻卡片),然后通过Webview展示出来。FIG. 2 is a schematic diagram of a search response interface provided by this embodiment. Specifically, in this embodiment, after recognizing the keyword input by the user in the browser search box (for example, Jay Chou in FIG. 2 ), the client terminal will The keyword is entered into the JavaScript interface in the web view Webview, and then notified to the WebView. Some js scripts in the WebView directly request to call the offline resource package, and obtain the html, css, js, resource files required for page display, etc. (as shown in Figure 2). Download card, news card below the search box), and then display it through Webview.
区别于相关技术中需要基于网络连接向服务端请求资源,本实施例基于本地缓存的离线资源包即可获取所需资源,可有效提高浏览器的页面加载速度,并且在网络连接异常时仍可正常进行页面加载,保证了页面加载的成功率。Different from the related art, which needs to request resources from the server based on the network connection, this embodiment can obtain the required resources based on the locally cached offline resource package, which can effectively improve the page loading speed of the browser, and can still be used when the network connection is abnormal. Page loading is performed normally to ensure the success rate of page loading.
在本实施例的一些实施方式中,在基于离线资源包输出对应于资源搜索请求的搜索结果页面之前,还包括:在网络连接状态为网络连接正常状态时,对本地缓存的离线资源包进行有效性分析。In some implementations of this embodiment, before outputting the search result page corresponding to the resource search request based on the offline resource package, the method further includes: when the network connection state is a normal network connection state, validating the locally cached offline resource package. Sexual Analysis.
具体的,在本实施例中,当网络连接正常时,考虑到向服务端请求资源再进行页面加载的速度较慢且会造成网络流量的耗费,本实施例在该场景下会优先考虑所缓存的离线资源包当前是否有效,在离线资源包有效时,仍旧基于离线资源包输出对应于资源搜索请求的搜索结果页面,以提升页面加载速度并节省网络流量。Specifically, in this embodiment, when the network connection is normal, considering that the speed of requesting resources from the server and then loading the page is slow and will cause network traffic consumption, this embodiment will give priority to the cached data in this scenario. Whether the offline resource package is currently valid, when the offline resource package is valid, the search result page corresponding to the resource search request is still output based on the offline resource package to improve page loading speed and save network traffic.
进一步地,在本实施例的一些实施方式中,对本地缓存的离线资源包进行有效性分析包括:获取服务端提供的在线资源包与本地缓存的离线资源包的差异性表征参数;基于差异性表征参数与预设参数阈值的比较结果,分析离线资源包的有效性。Further, in some implementations of this embodiment, the validity analysis of the locally cached offline resource package includes: obtaining a difference characterizing parameter between the online resource package provided by the server and the locally cached offline resource package; based on the difference The comparison results of the characterization parameters and the preset parameter thresholds are used to analyze the effectiveness of offline resource packs.
具体的,在实际应用中,可以针对本地缓存的离线资源包预置一个有效期,到有效期到达时,该离线资源包失效。而本实施例为了提升资源包有效性判断的准确性,可以将离线资源包与服务端当前提供的资源包的差异性进行分析,并通过差异性分析结果来确定离线资源包的有效性。应当理解的是,本实施例的差异性表征参数可以是基于离线资源包的版本号与在线资源包的版本号所得到的版本差异值,在版本差异值低于预设值时,说明离线资源包为相对较新或最新版本,从而离线资源包有效,反之则为较旧的历史版本,从而离线资源包无效。Specifically, in practical applications, a validity period may be preset for the locally cached offline resource package, and when the validity period arrives, the offline resource package becomes invalid. In this embodiment, in order to improve the accuracy of judging the validity of the resource package, the difference between the offline resource package and the resource package currently provided by the server can be analyzed, and the validity of the offline resource package can be determined according to the difference analysis result. It should be understood that the difference characterizing parameter in this embodiment may be a version difference value obtained based on the version number of the offline resource package and the version number of the online resource package. When the version difference value is lower than the preset value, the offline resource is indicated. The package is relatively new or the latest version, so the offline resource pack is valid, otherwise it is an older historical version, so the offline resource pack is invalid.
进一步地,在本实施例的一些实施方式中,在离线资源包无效时,则可获取服务端提供的在线资源包,并基于在线资源包输出对应于资源搜索请求的搜索结果页面,并通过在线资源包更新本地缓存的离线资源包。Further, in some implementations of this embodiment, when the offline resource package is invalid, the online resource package provided by the server can be obtained, and based on the online resource package, a search result page corresponding to the resource search request can be output, and the online resource package can be obtained through the online resource package. Resource bundles update locally cached offline resource bundles.
具体的,在本实施例中,若离线资源包失效时,说明通过该资源包所加载的页面并不能很好的满足用户的搜索需求,从而利用当前网络连接向服务侧进行资源请求,并以此来进行搜索结果页面的正常加载。另外,本实施例还通过本次向服务器请求的资源包来对本地缓存的资源包进行更新,以对浏览器客户端离线加载页面的功能进行修复。Specifically, in this embodiment, if the offline resource package is invalid, it means that the page loaded through the resource package cannot well meet the user's search requirements, so the resource request is made to the service side by using the current network connection, and the This is for normal loading of the search results page. In addition, this embodiment also updates the locally cached resource package through the resource package requested from the server this time, so as to repair the function of the browser client to load the page offline.
如图3所示为本实施例提供的一种离线资源包更新方法的流程示意图,更进一步地,在本实施例的一些实施方式中,在通过在线资源包更新本地缓存的离线资源包时,具体包括如下步骤:FIG. 3 is a schematic flowchart of a method for updating an offline resource package provided by this embodiment. Further, in some implementations of this embodiment, when updating a locally cached offline resource package through an online resource package, Specifically include the following steps:
步骤301、分析在线资源包中各资源的资源属性;
步骤302、基于资源属性分别判断各资源是否满足资源更新条件;Step 302: Determine whether each resource satisfies the resource update condition based on the resource attribute;
步骤303、通过在线资源包中满足资源更新条件的资源,更新本地缓存的离线资源包。Step 303 : Update the locally cached offline resource package by using the resources in the online resource package that satisfy the resource update condition.
具体的,在本实施例中,考虑到并非服务端新发版本的资源包中所有资源均为用户以期的资源,本实施例可以通过在线资源包中各资源的资源属性确定对资源是否需要进行拦截处理等,由此以确定各资源是否具有更新需求,然后在原先缓存的离线资源包中,对切实具有更新需求的资源进行更新。相对于完全通过所在线获取的资源包来对本地缓存的资源包进行替换的粗粒度更新方式,本实施方式所提供的仅对特定资源文件进行部分更新的细粒度更新方式更为灵活可控。Specifically, in this embodiment, considering that not all the resources in the resource package of the newly released version of the server are the resources expected by the user, this embodiment can determine whether the resource needs to be processed according to the resource attributes of each resource in the online resource package. Intercept processing, etc., to determine whether each resource has an update requirement, and then update the resource that actually has an update requirement in the originally cached offline resource package. Compared with the coarse-grained update method of replacing the locally cached resource packs entirely through the resource packs obtained online, the fine-grained update method of only partially updating a specific resource file provided by this embodiment is more flexible and controllable.
如图4所示为本实施例提供的另一种离线资源包更新方法的流程示意图,在本实施例的一些实施方式中,该离线资源包更新方法具体包括如下步骤:FIG. 4 is a schematic flowchart of another offline resource package update method provided in this embodiment. In some implementations of this embodiment, the offline resource package update method specifically includes the following steps:
步骤401、向服务端发送携带有离线资源包的唯一标识的资源包更新请求;
步骤402、接收服务端反馈的差量更新资源包;
步骤403、基于差量更新资源包更新本地缓存的离线资源包。Step 403: Update the locally cached offline resource package based on the differential update resource package.
具体的,本实施例的差量更新资源包包括:服务端提供的最新在线资源包中,唯一标识所对应的历史修改节点与最新节点之间的所有差量资源,唯一标识可以是采用信息摘要算法所计算的信息摘要值例如MD5值或版本号。Specifically, the differential update resource package in this embodiment includes: in the latest online resource package provided by the server, all differential resources between the corresponding historical modification node and the latest node are uniquely identified, and the unique identification may be the use of information digest The message digest value computed by the algorithm is, for example, an MD5 value or a version number.
在实际应用中,浏览器客户端通常会向服务端请求全量资源包,一方面会对服务端造成较大负载,另一方面还会加大客户端的网络流量和电量耗费,以及降低了客户端的资源包更新速度。基于此考虑,本实施例提出了一种差量更新方法,也即当客户端需要进行资源包更新时,将所缓存的离线资源包的唯一标识上报至服务端,服务端基于客户端侧的资源包的唯一标识,在自身可提供的最新资源包中定位对应的修改节点,然后基于修改节点与最新节点之间的所有修改操作记录生成差量更新资源包,该差量更新资源包是某个历史版本的资源包与最新版本资源包之间的差量。应当理解的是,服务端的资源包通常由专门的开发人员进行维护,也即对资源进行增、删、改等修改操作,每一个修改操作都可以视为一个原子操作,针对每个修改操作,都记录下相关修改操作记录,与此同时也可以对每个修改操作后所得到的资源包的唯一标识进行记录,由此可以与客户端上报的唯一标识进行匹配,从而定位客户端侧资源包所处修改节点。In practical applications, the browser client usually requests the full resource package from the server. Resource pack update speed. Based on this consideration, this embodiment proposes a differential update method, that is, when the client needs to update the resource package, the unique identifier of the cached offline resource package is reported to the server, and the server is based on the client side. The unique identifier of the resource package, locate the corresponding modified node in the latest resource package that it can provide, and then generate a differential update resource package based on all modification operation records between the modified node and the latest node. The differential update resource package is a certain update resource package. The difference between the previous version of the resource pack and the latest version of the resource pack. It should be understood that the resource package of the server is usually maintained by specialized developers, that is, the modification operations such as adding, deleting, and modifying resources are performed. Each modification operation can be regarded as an atomic operation. For each modification operation, The relevant modification operation records are recorded. At the same time, the unique identifier of the resource package obtained after each modification operation can also be recorded, so that it can be matched with the unique identifier reported by the client, thereby locating the client-side resource package. where to modify the node.
由此,客户端通过差量更新资源包进行本地资源包更新,更新的数据量大大减小,降低了服务端负载以及客户端的网络流量/电量耗费,并大大加快了客户端更新速度。As a result, the client updates the local resource package through the differential update resource package, the amount of updated data is greatly reduced, the load of the server and the network traffic/power consumption of the client are reduced, and the update speed of the client is greatly accelerated.
基于上述本申请实施例的技术方案,在接收到资源搜索请求时,确定当前的网络连接状态;在网络连接状态为网络连接异常状态时,获取本地缓存的离线资源包;基于离线资源包输出对应于资源搜索请求的搜索结果页面。通过本申请方案的实施,在本地缓存有离线资源包,若网络连接异常时,直接根据离线资源包对用户的资源搜索请求进行响应,有效提高了页面加载速度,并保证了页面加载的成功率。Based on the technical solutions of the above embodiments of the present application, when a resource search request is received, the current network connection state is determined; when the network connection state is an abnormal state of the network connection, a locally cached offline resource package is obtained; based on the offline resource package output corresponding The search results page for resource search requests. Through the implementation of the solution of the present application, the offline resource package is cached locally. If the network connection is abnormal, the user's resource search request is directly responded to the offline resource package, which effectively improves the page loading speed and ensures the success rate of page loading. .
图5中的方法为本申请第二实施例提供的一种细化的搜索响应方法,应用于浏览器客户端,该搜索响应方法包括:The method in FIG. 5 is a refined search response method provided by the second embodiment of the present application, applied to a browser client, and the search response method includes:
步骤501、在接收到资源搜索请求时,确定当前的网络连接状态。Step 501: When a resource search request is received, determine the current network connection state.
具体的,本实施例的搜索响应方法可以应用于搜索直达场景,也即当客户端检测到用户在浏览器搜索框输入的字符时,生成资源搜索请求,也可以应用于普通搜索场景,也即当用户在浏览器搜索框输入字符之后,触发搜索控件生成资源搜索请求。Specifically, the search response method in this embodiment can be applied to a direct search scenario, that is, when the client detects the characters entered by the user in the browser search box, and generates a resource search request, it can also be applied to a common search scenario, that is After the user enters characters in the browser search box, the search control is triggered to generate a resource search request.
步骤502、在网络连接状态为网络连接异常状态时,获取本地缓存的离线资源包。Step 502: When the network connection state is an abnormal state of the network connection, obtain a locally cached offline resource package.
具体的,本实施例在客户端本地缓存有html5页面的资源包,该资源包内可以包括html,css,js,jpg文件等,离线资源包用于客户端在离线状态下加载页面。Specifically, in this embodiment, a resource package of an html5 page is cached locally on the client side, and the resource package may include html, css, js, jpg files, etc. The offline resource package is used for the client to load pages in an offline state.
步骤503、基于离线资源包输出对应于资源搜索请求的搜索结果页面。
具体的,本实施例客户端将用户输入的关键词输入到Webview中的JavaScript接口,然后通知到下方的WebView,WebView里面一些js脚本直接请求调用离线资源包,从中获取页面展示所需的html、css、js、resource文件等,然后通过Webview展示出来。Specifically, in this embodiment, the client inputs the keywords input by the user into the JavaScript interface in the Webview, and then notifies the WebView below. Some js scripts in the WebView directly request to call the offline resource package, and obtain the html, css, js, resource files, etc., and then displayed through Webview.
步骤504、在网络连接状态为网络连接正常状态时,对本地缓存的离线资源包进行有效性分析。Step 504: When the network connection state is the normal state of the network connection, perform validity analysis on the locally cached offline resource package.
步骤505、在离线资源包无效时,向服务端发送携带有离线资源包的唯一标识的资源包更新请求。Step 505: When the offline resource package is invalid, send a resource package update request carrying the unique identifier of the offline resource package to the server.
具体的,本实施例在网络连接正常时,若确定此前所缓存的离线资源包失效,则通过网络连接向服务端请求资源包更新,以保证后续网络连接异常下可正常使用离线加载页面功能。当客户端需要进行资源包更新时,将所缓存的离线资源包的唯一标识上报至服务端,以使服务端感知客户端当前所缓存的资源包版本。Specifically, in this embodiment, when the network connection is normal, if it is determined that the previously cached offline resource package is invalid, the resource package update is requested to the server through the network connection, so as to ensure that the offline page loading function can be normally used in the subsequent abnormal network connection. When the client needs to update the resource package, the unique identifier of the cached offline resource package is reported to the server, so that the server can perceive the version of the resource package currently cached by the client.
步骤506、接收服务端反馈的差量更新资源包。Step 506: Receive the differential update resource package fed back by the server.
具体的,本实施例的差量更新资源包包括:服务端提供的最新在线资源包中,唯一标识所对应的历史修改节点与最新节点之间的所有差量资源。服务端基于客户端侧的资源包的唯一标识,在自身可提供的最新资源包中定位对应的修改节点,然后基于修改节点与最新节点之间的所有修改操作记录生成差量更新资源包,该差量更新资源包是某个历史版本的资源包与最新版本资源包之间的差量。Specifically, the differential update resource package in this embodiment includes: in the latest online resource package provided by the server, all differential resources between the corresponding historical modification node and the latest node are uniquely identified. Based on the unique identifier of the resource package on the client side, the server locates the corresponding modified node in the latest resource package that it can provide, and then generates a differential update resource package based on all modification operation records between the modified node and the latest node. The delta update resource pack is the difference between a resource pack of a certain historical version and the resource pack of the latest version.
步骤507、基于差量更新资源包更新本地缓存的离线资源包。Step 507: Update the locally cached offline resource package based on the differential update resource package.
在本实施例中,客户端通过差量更新资源包进行本地资源包更新,更新的数据量大大减小,降低了服务端负载以及客户端的网络流量/电量耗费,并大大加快了客户端更新速度。In this embodiment, the client updates the local resource package by updating the resource package differentially, the amount of updated data is greatly reduced, the load of the server and the network traffic/power consumption of the client are reduced, and the update speed of the client is greatly accelerated. .
应当理解的是,本实施例中各步骤的序号的大小并不意味着步骤执行顺序的先后,各步骤的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成唯一限定。It should be understood that the size of the sequence numbers of the steps in this embodiment does not imply the order of execution of the steps, and the execution sequence of the steps should be determined by its functions and internal logic, and should not constitute the implementation process of the embodiments of the present application. only limited.
本申请实施例公开了一种搜索响应方法,在接收到资源搜索请求时,确定当前的网络连接状态;在网络连接状态为网络连接异常状态时,获取本地缓存的离线资源包;基于离线资源包输出对应于资源搜索请求的搜索结果页面;在网络连接状态为网络连接正常状态时,向服务端请求差量更新资源包;基于差量更新资源包更新本地缓存的离线资源包。通过本申请方案的实施,在本地缓存有离线资源包,若网络连接异常时,直接根据离线资源包对用户的资源搜索请求进行响应,有效提高了页面加载速度,并保证了页面加载的成功率;另外,在网络连接正常时,通过差量更新资源包进行本地资源包更新,降低了服务端负载以及客户端的网络流量/电量耗费,并大大加快了客户端更新速度。The embodiment of the present application discloses a search response method. When a resource search request is received, the current network connection state is determined; when the network connection state is an abnormal network connection state, a locally cached offline resource package is obtained; based on the offline resource package Output the search result page corresponding to the resource search request; when the network connection status is the normal state of the network connection, request a differential update resource pack from the server; update the locally cached offline resource pack based on the differential update resource pack. Through the implementation of the solution of the present application, the offline resource package is cached locally. If the network connection is abnormal, the user's resource search request is directly responded to the offline resource package, which effectively improves the page loading speed and ensures the success rate of page loading. ; In addition, when the network connection is normal, the local resource package update is performed through the differential update resource package, which reduces the server load and the client's network traffic/power consumption, and greatly speeds up the client update speed.
图6为本申请第三实施例提供的一种搜索响应装置。该搜索响应装置可用于实现前述实施例中的搜索响应方法。如图6所示,该搜索响应装置主要包括:FIG. 6 is a search response apparatus provided by a third embodiment of the present application. The search response apparatus can be used to implement the search response method in the foregoing embodiments. As shown in Figure 6, the search response device mainly includes:
确定模块601,用于在接收到资源搜索请求时,确定当前的网络连接状态;A
获取模块602,用于在网络连接状态为网络连接异常状态时,获取本地缓存的离线资源包;an obtaining
输出模块603,用于基于离线资源包输出对应于资源搜索请求的搜索结果页面。The
在本实施例的一些实施方式中,获取模块602具体用于:获取输入资源搜索请求的用户的搜索响应需求;基于搜索响应需求从本地缓存的多个离线资源包中,获取对应的离线资源包。In some implementations of this embodiment, the obtaining
如图7所示为本实施例提供的另一种搜索响应装置的功能模块示意图,在本实施例的一些实施方式中,搜索响应装置还包括更新模块604,用于:向服务端发送携带有离线资源包的唯一标识的资源包更新请求;接收服务端反馈的差量更新资源包,其中,差量更新资源包包括:服务端提供的最新在线资源包中,唯一标识所对应的历史修改节点与最新节点之间的所有差量资源;基于差量更新资源包更新本地缓存的离线资源包。FIG. 7 is a schematic diagram of functional modules of another search response apparatus provided in this embodiment. In some implementations of this embodiment, the search response apparatus further includes an
请再次参阅图7,在本实施例一些实施方式中,搜索响应装置还包括分析模块605,用于:在基于离线资源包输出对应于资源搜索请求的搜索结果页面之前,在网络连接状态为网络连接正常状态时,对本地缓存的离线资源包进行有效性分析。相对应的,输出模块603具体用于:在离线资源包有效时,基于离线资源包输出对应于资源搜索请求的搜索结果页面。Referring to FIG. 7 again, in some implementations of this embodiment, the search response apparatus further includes an
进一步地,在本实施例一些实施方式中,分析模块605具体用于:获取服务端提供的在线资源包与本地缓存的离线资源包的差异性表征参数;基于差异性表征参数与预设参数阈值的比较结果,分析离线资源包的有效性。Further, in some implementations of this embodiment, the
进一步地,在本实施例的另一些实施方式中,获取模块602还用于:在对本地缓存的离线资源包进行有效性分析之后,在离线资源包无效时,获取服务端提供的在线资源包;输出模块603还用于:基于在线资源包输出对应于资源搜索请求的搜索结果页面;更新模块604还用于:通过在线资源包更新本地缓存的离线资源包。Further, in other implementations of this embodiment, the obtaining
更进一步地,在本实施例的一些实施方式中,更新模块604在执行通过在线资源包更新本地缓存的离线资源包的功能时,具体用于:分析在线资源包中各资源的资源属性;基于资源属性分别判断各资源是否满足资源更新条件;通过在线资源包中满足资源更新条件的资源,更新本地缓存的离线资源包。Further, in some implementations of this embodiment, when the
应当说明的是,第一、二实施例中的搜索响应方法均可基于本实施例提供的搜索响应装置实现,所属领域的普通技术人员可以清楚的了解到,为描述的方便和简洁,本实施例中所描述的搜索响应装置的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。It should be noted that the search response methods in the first and second embodiments can be implemented based on the search response device provided in this embodiment. Those of ordinary skill in the art can clearly understand that, for the convenience and brevity of description, this implementation For the specific working process of the search response apparatus described in the example, reference may be made to the corresponding process in the foregoing method embodiments, which will not be repeated here.
根据本实施例所提供的搜索响应装置,在接收到资源搜索请求时,确定当前的网络连接状态;在网络连接状态为网络连接异常状态时,获取本地缓存的离线资源包;基于离线资源包输出对应于资源搜索请求的搜索结果页面。通过本申请方案的实施,在本地缓存有离线资源包,若网络连接异常时,直接根据离线资源包对用户的资源搜索请求进行响应,有效提高了页面加载速度,并保证了页面加载的成功率。According to the search response device provided in this embodiment, when a resource search request is received, the current network connection state is determined; when the network connection state is an abnormal network connection state, a locally cached offline resource package is obtained; based on the offline resource package output The search results page corresponding to the resource search request. Through the implementation of the solution of the present application, the offline resource package is cached locally. If the network connection is abnormal, the user's resource search request is directly responded to the offline resource package, which effectively improves the page loading speed and ensures the success rate of page loading. .
请参阅图8,图8为本申请第四实施例提供的一种电子装置。该电子装置可用于实现前述实施例中的搜索响应方法。如图8所示,该电子装置主要包括:Please refer to FIG. 8 . FIG. 8 is an electronic device according to a fourth embodiment of the present application. The electronic device can be used to implement the search response method in the foregoing embodiments. As shown in Figure 8, the electronic device mainly includes:
存储器801、处理器802、总线803及存储在存储器801上并可在处理器802上运行的计算机程序,存储器801和处理器802通过总线803连接。处理器802执行该计算机程序时,实现前述实施例中的搜索响应方法。其中,处理器的数量可以是一个或多个。A
存储器801可以是高速随机存取记忆体(RAM,Random Access Memory)存储器,也可为非不稳定的存储器(non-volatile memory),例如磁盘存储器。存储器801用于存储可执行程序代码,处理器802与存储器801耦合。The
进一步的,本申请实施例还提供了一种计算机可读存储介质,该计算机可读存储介质可以是设置于上述各实施例中的电子装置中,该计算机可读存储介质可以是前述图8所示实施例中的存储器。Further, an embodiment of the present application also provides a computer-readable storage medium, which may be provided in the electronic device in the above-mentioned embodiments, and the computer-readable storage medium may be the one shown in FIG. 8 above. memory in the example embodiment.
该计算机可读存储介质上存储有计算机程序,该程序被处理器执行时实现前述实施例中的搜索响应方法。进一步的,该计算机可存储介质还可以是U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、RAM、磁碟或者光盘等各种可以存储程序代码的介质。A computer program is stored on the computer-readable storage medium, and when the program is executed by the processor, the search response method in the foregoing embodiment is implemented. Further, the computer-storable medium may also be a USB flash drive, a removable hard disk, a read-only memory (ROM, Read-Only Memory), a RAM, a magnetic disk, or an optical disk and other media that can store program codes.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,模块的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个模块或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或模块的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the device embodiments described above are only illustrative. For example, the division of modules is only a logical function division. In actual implementation, there may be other division methods, for example, multiple modules or components may be combined or integrated. to another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of devices or modules, and may be in electrical, mechanical or other forms.
作为分离部件说明的模块可以是或者也可以不是物理上分开的,作为模块显示的部件可以是或者也可以不是物理模块,即可以位于一个地方,或者也可以分布到多个网络模块上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。Modules described as separate components may or may not be physically separated, and components shown as modules may or may not be physical modules, that is, they may be located in one place, or may be distributed to multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution in this embodiment.
另外,在本申请各个实施例中的各功能模块可以集成在一个处理模块中,也可以是各个模块单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。In addition, each functional module in each embodiment of the present application may be integrated into one processing module, or each module may exist physically alone, or two or more modules may be integrated into one module. The above-mentioned integrated modules can be implemented in the form of hardware, and can also be implemented in the form of software function modules.
集成的模块如果以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个可读存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例方法的全部或部分步骤。而前述的可读存储介质包括:U盘、移动硬盘、ROM、RAM、磁碟或者光盘等各种可以存储程序代码的介质。The integrated modules, if implemented in the form of software functional modules and sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, and the computer software products are stored in a readable storage The medium includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present application. The aforementioned readable storage medium includes: U disk, removable hard disk, ROM, RAM, magnetic disk or optical disk and other media that can store program codes.
需要说明的是,对于前述的各方法实施例,为了简便描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其它顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定都是本申请所必须的。It should be noted that, for the convenience of description, the foregoing method embodiments are described as a series of action combinations, but those skilled in the art should know that the present application is not limited by the described action sequence. Because in accordance with the present application, certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily all necessary for the present application.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其它实施例的相关描述。In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference may be made to the relevant descriptions of other embodiments.
以上为对本申请所提供的搜索响应方法、装置及计算机可读存储介质的描述,对于本领域的技术人员,依据本申请实施例的思想,在具体实施方式及应用范围上均会有改变之处,综上,本说明书内容不应理解为对本申请的限制。The above is a description of the search response method, device and computer-readable storage medium provided by this application. For those skilled in the art, according to the ideas of the embodiments of this application, there will be changes in the specific implementation and application scope. , to sum up, the content of this specification should not be construed as a limitation on this application.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010920889.0A CN111966937A (en) | 2020-09-04 | 2020-09-04 | Search response method and device and computer readable storage medium |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202010920889.0A CN111966937A (en) | 2020-09-04 | 2020-09-04 | Search response method and device and computer readable storage medium |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN111966937A true CN111966937A (en) | 2020-11-20 |
Family
ID=73392153
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202010920889.0A Pending CN111966937A (en) | 2020-09-04 | 2020-09-04 | Search response method and device and computer readable storage medium |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN111966937A (en) |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105681380A (en) * | 2014-11-20 | 2016-06-15 | 阿里巴巴集团控股有限公司 | Client offline method and system thereof |
| US20170017672A1 (en) * | 2015-07-14 | 2017-01-19 | Microsoft Technology Licensing, Llc | Accessing search results in offline mode |
| CN107784086A (en) * | 2017-10-09 | 2018-03-09 | 中国平安人寿保险股份有限公司 | A kind of loading method of webpage, terminal device and computer-readable recording medium |
| CN108132814A (en) * | 2017-12-22 | 2018-06-08 | 平安养老保险股份有限公司 | Page loading method, device, computer equipment and the storage medium of application program |
| CN111314426A (en) * | 2020-01-17 | 2020-06-19 | 北京达佳互联信息技术有限公司 | Webpage resource obtaining method and device, electronic equipment and storage medium |
-
2020
- 2020-09-04 CN CN202010920889.0A patent/CN111966937A/en active Pending
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN105681380A (en) * | 2014-11-20 | 2016-06-15 | 阿里巴巴集团控股有限公司 | Client offline method and system thereof |
| US20170017672A1 (en) * | 2015-07-14 | 2017-01-19 | Microsoft Technology Licensing, Llc | Accessing search results in offline mode |
| CN107784086A (en) * | 2017-10-09 | 2018-03-09 | 中国平安人寿保险股份有限公司 | A kind of loading method of webpage, terminal device and computer-readable recording medium |
| CN108132814A (en) * | 2017-12-22 | 2018-06-08 | 平安养老保险股份有限公司 | Page loading method, device, computer equipment and the storage medium of application program |
| CN111314426A (en) * | 2020-01-17 | 2020-06-19 | 北京达佳互联信息技术有限公司 | Webpage resource obtaining method and device, electronic equipment and storage medium |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN110263275B (en) | Method and device for accessing webpage, mobile terminal and storage medium | |
| US9077681B2 (en) | Page loading optimization using page-maintained cache | |
| CN110062025A (en) | Method, apparatus, server and the storage medium of data acquisition | |
| CN110262807B (en) | Cluster creation progress log acquisition system, method and device | |
| CN109376318B (en) | A page loading method, computer readable storage medium and terminal device | |
| CN112000394B (en) | Method, apparatus, device and storage medium for accessing applet | |
| CN113536168B (en) | Component processing methods and equipment | |
| CN111475180A (en) | Method and system for updating client cache | |
| CN111200634B (en) | Cache resource linkage updating method, system and server | |
| CN107544849A (en) | A kind of WEB server concurrency management method and system | |
| CN111767053A (en) | A kind of front-end page data acquisition method and device | |
| CN110019263A (en) | Information storage means and device | |
| CN110598135A (en) | Network request processing method and device, computer readable medium and electronic equipment | |
| CN113806655A (en) | Data processing method and device, electronic equipment and storage medium | |
| CN117193907B (en) | Page processing method and device | |
| CN113157480A (en) | Error information processing method, device, storage medium and terminal | |
| CN111966937A (en) | Search response method and device and computer readable storage medium | |
| US20240089339A1 (en) | Caching across multiple cloud environments | |
| CN118797194A (en) | Data acquisition method, device, electronic device and storage medium | |
| CN112699116A (en) | Data processing method and system | |
| CN115277857A (en) | Method and device for interface verification, electronic equipment and storage medium | |
| US20150222505A1 (en) | Business transaction resource usage tracking | |
| CN112527531A (en) | Cache processing method and system | |
| US11954538B2 (en) | Updating a state of a client device using a limited event size protocol | |
| CN112269954B (en) | Method and device for determining page usage duration |
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 |
Application publication date: 20201120 |
|
| RJ01 | Rejection of invention patent application after publication |