WO2019000722A1 - Hypertext markup language webpage loading method and device - Google Patents

Hypertext markup language webpage loading method and device Download PDF

Info

Publication number
WO2019000722A1
WO2019000722A1 PCT/CN2017/107041 CN2017107041W WO2019000722A1 WO 2019000722 A1 WO2019000722 A1 WO 2019000722A1 CN 2017107041 W CN2017107041 W CN 2017107041W WO 2019000722 A1 WO2019000722 A1 WO 2019000722A1
Authority
WO
WIPO (PCT)
Prior art keywords
webpage
client
cache
cached
resource
Prior art date
Application number
PCT/CN2017/107041
Other languages
French (fr)
Chinese (zh)
Inventor
陈娇
张文明
陈少杰
Original Assignee
武汉斗鱼网络科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 武汉斗鱼网络科技有限公司 filed Critical 武汉斗鱼网络科技有限公司
Publication of WO2019000722A1 publication Critical patent/WO2019000722A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/955Retrieval from the web using information identifiers, e.g. uniform resource locators [URL]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching

Definitions

  • the present invention relates to the field of application development technologies, and in particular, to a hypertext markup language webpage loading method and apparatus.
  • HyperText Markup Language is a markup language applied to web pages, through which markup languages can be created. For web pages created with HTML, in order to reduce the frequency of access to physical data sources and improve running performance, such web pages will be cached while being loaded.
  • the prior art needs to initiate two network requests to the web server, which are: a network request for webpage loading and a network request for webpage caching. Not only does the load cache have low efficiency, but it also wastes traffic.
  • the present invention has been made in order to provide a hypertext markup language web page loading method and apparatus that overcomes the above problems or at least partially solves the above problems.
  • the embodiment of the invention provides a hypertext markup language webpage loading method, which is applied to a client, and the method includes:
  • the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
  • the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
  • the type of the webpage is HTML5.
  • the OkHttp framework is used to initiate a network request to the network server, so that a data transmission pipeline flow is established between the web server and the client, including :
  • the webpage resource is not cached in the client, determining whether the webpage resource belongs to a cache whitelist and a cache blacklist, wherein the cache whitelist has a first cache condition that allows resource cache, Having a second cache condition in the cache blacklist that does not allow resource cache, the first cache condition being different from the second cache condition;
  • the OkHttp framework is used to initiate a network request to the network server, so that a data transmission pipeline flow is established between the web server and the client. Otherwise, it returns empty and does not cache the web resource.
  • the determining, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client includes:
  • the webpage resource address exists in the cache database, it indicates that the webpage resource is cached in the client. If the webpage resource address does not exist in the cache database, the webpage resource is not Cache in the client.
  • the method before the searching for the webpage resource address in the cache data included in the cache database, the method further includes:
  • the method further comprises:
  • the synchronizing the currently read network resource data including:
  • the webpage resource address corresponding to the currently read network resource data is synchronously cached into the cache database.
  • the embodiment of the invention further provides a hypertext markup language webpage loading device, the device comprising:
  • An obtaining module configured to obtain a webpage resource address for a webpage based on a hypertext markup language
  • a determining module configured to determine, according to the webpage resource address, whether a webpage resource corresponding to the webpage resource address is cached in the client;
  • a loading module configured to read the webpage resource from the client and load display if the webpage resource is already cached in the client;
  • a request initiating module if the webpage resource is not cached in the client, using a OkHttp framework to initiate a network request to the network server, so as to establish a data transmission pipeline flow between the web server and the client;
  • Loading a cache module configured to perform synchronous loading display on the currently read network resource data in the process of reading the network resource data returned by the data transmission pipeline flow, and simultaneously perform current read network resource data Synchronous cache.
  • the embodiment of the invention further provides a computer readable storage medium, on which a computer program is stored, and when the program is executed by the processor, the following steps are implemented:
  • the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
  • the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
  • the embodiment of the invention further provides a computer device, comprising a memory, a processor and a computer program stored on the memory and operable on the processor, the processor implementing the program to implement the following steps:
  • the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
  • the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
  • the present application is directed to an HTML webpage.
  • the webpage resource address is first obtained, and then the webpage resource corresponding to the webpage resource address is cached in the client locality. If the webpage resource is cached in the client locality, the client is from the client. The local end reads the webpage resource and loads the display.
  • the OkHttp framework is used to initiate a network request to the web server, so that a data transmission pipeline flow is established between the web server and the client, and the client Read data transmission pipeline
  • the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached, and the application only needs one network request to implement the pair. Uncached network resources are loaded and cached, which improves the efficiency of loading caches and saves traffic.
  • the repeated network requests can be automatically filtered out.
  • FIG. 1 is a flowchart of a method for loading a hypertext markup language webpage in an embodiment of the present invention
  • FIG. 2 is a structural diagram of a hypertext markup language webpage loading apparatus in an embodiment of the present invention
  • FIG. 3 is a schematic diagram showing the physical structure of a computer device in an embodiment of the present invention.
  • the embodiment of the present application provides a hypertext markup language webpage loading method, which is applied to a client. As shown in FIG. 1, the method includes:
  • Step 101 Obtain a webpage resource address for a webpage based on a hypertext markup language.
  • Step 102 Determine, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client.
  • Step 103 If the webpage resource is already cached in the client, read the webpage resource from the client and load display; if the webpage resource is not cached in the client, use The OkHttp framework initiates a network request to the network server to establish a data transmission pipeline flow between the network server and the client.
  • Step 104 During the process of reading the network resource data returned by the data transmission pipeline flow, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
  • the present application is directed to an HTML webpage.
  • the webpage resource address is first obtained, and then the webpage resource corresponding to the webpage resource address is cached in the client locality. If the webpage resource is cached in the client locality, the client is from the client. The local end reads the webpage resource and loads the display.
  • the OkHttp framework is used to initiate a network request to the web server, so that a data transmission pipeline flow is established between the web server and the client, and the client During the process of reading the network resource data returned by the data transmission pipeline flow, the network resource data currently read is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached, and the application only needs to be once.
  • the network request can load and cache the uncached network resources, improve the efficiency of loading cache, save traffic, and automatically initiate filtering of duplicate network requests by using the OkHttp framework to initiate the network request.
  • the type of the webpage may be HTML5.
  • the method of the present application can be established in the BasicWebViewClient class, thereby replacing the WebViewClient in the prior art by using the BasicWebViewClient class.
  • the internal loading process of the BasicWebViewClient class is described in detail below.
  • step 101 first, the page resource address (Uniform Resource Locator, URL) in the web page to be loaded may be intercepted by the shouldlnterceptRequest to obtain the URL, and then step 102 is performed.
  • a preferred embodiment of step 102 includes:
  • the cache database is located locally on the client, and the cached database stores cached cache data.
  • the cache data includes a URL, a cached webpage resource, and a correspondence between the two.
  • the cache database includes URL1 and URL1.
  • the present application can determine whether a webpage resource corresponding to the webpage resource address is cached in the client locality by searching whether the webpage resource address exists in the cache data included in the cache database, and if the webpage resource exists in the cached data included in the cache database.
  • the address indicates that the webpage resource corresponding to the webpage resource address is cached locally on the client. If the webpage resource address does not exist in the cached data included in the cache database, the webpage resource corresponding to the webpage resource address is not cached locally on the client. .
  • the present application further includes the steps of: obtaining the cached data from the cache database, and storing the cached data in a Map set, before performing the lookup of whether the webpage resource address exists in the cache database including the cache data.
  • step 103 if the webpage resource corresponding to the webpage resource address is cached locally on the client, the webpage resource is locally read from the client and loaded, and the webpage resource corresponding to the webpage resource address is not cached on the client.
  • Local use the OkHttp framework to launch a network to the web server. Soliciting a data transmission pipeline flow between the network server and the client.
  • the OkHttp framework is used to initiate a network request to the network server to establish a connection between the web server and the client.
  • Data transfer pipeline flow including:
  • the webpage resource is not cached in the client, determining whether the webpage resource belongs to a cache whitelist and a cache blacklist, wherein the cache whitelist has a first cache condition that allows resource cache, Having a second cache condition in the cache blacklist that does not allow resource cache, the first cache condition being different from the second cache condition;
  • the OkHttp framework is used to initiate a network request to the network server, so that a data transmission pipeline flow is established between the web server and the client. Otherwise, it returns empty and does not cache the web resource.
  • the webpage resource corresponding to the webpage resource address is not cached locally on the client, it is determined whether the webpage resource belongs to the cache whitelist, and whether the webpage resource belongs to the cached blacklist, the cached whitelist, and the cached blacklist.
  • Each of the cached whitelists has a first cache condition
  • the cached blacklist has a second cache condition
  • the first cache condition and the second cache condition are different.
  • the webpage resource belongs to the cache whitelist and does not belong to the cache blacklist, it indicates that the webpage resource has the cache qualification. If the webpage resource belongs to the cached blacklist, it indicates that the webpage resource does not have the cache qualification, and if the webpage resource does not belong to the cache.
  • the whitelist is also not a cached blacklist, indicating that the webpage resource is not eligible for caching.
  • the first cache condition in the cache whitelist is the domain name baidu
  • the second cache condition in the cache blacklist is suffix JPG
  • the domain name of the first webpage resource is baidu suffix PNG
  • the domain name of the second webpage resource is baidu suffix is JPG
  • the second webpage resource does not have the cache qualification, returns null, does not cache the second webpage resource
  • the third webpage If the domain name of the resource is google suffixed as PNG, the third webpage resource does not have the cache qualification, and returns null, and does not cache the second webpage resource.
  • the present application utilizes the OkHttp framework to initiate a network request to the network server to establish a data transmission pipeline flow between the network server and the client, and the data transmission pipeline flow includes an input pipeline flow (PipedInputStream) and an output pipeline flow (PipedOutputStream).
  • the present application utilizes the data transmission pipeline flow to implement direct communication between the main thread and the sub-thread, and can realize display while downloading, specifically, in the process of reading the network resource data returned by the data transmission pipeline flow, the current reading
  • the obtained network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
  • the web resource address corresponding to the currently read network resource data is used in this application.
  • Synchronous caching into the cache database In this application, data pipeline flow How much data is in the webpage, how much content is displayed in the webpage, the webpage resource is loaded, and the cached data is also written. Finally, the cached cached data path and the deposit time are written into the cache database.
  • the Hypertext Markup Language webpage loading method of the present application further includes:
  • the attribute information of the webpage resource cached locally on the client can be found in the database cache list, and the cache time of the webpage resource cached locally on the client is the difference between the deposit time and the current time. If the difference between the inbound time and the current time is greater than the preset cache period, the webpage resources cached on the client are deleted. If the cache time does not exceed the preset cache period, the reservation is continued.
  • the preset cache period can be set to one day and one week. Or one month.
  • the method further includes: determining whether the URL is a normal URL, and if yes, The subsequent loading cache process is executed. If not, it returns directly to the empty, and does not perform the load caching process.
  • an embodiment of the present invention further provides a hypertext markup language webpage loading device. As shown in FIG. 2, the device includes:
  • the obtaining module 201 is configured to obtain a webpage resource address for a webpage based on a hypertext markup language
  • the determining module 202 is configured to determine, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client;
  • the loading module 203 is configured to: if the webpage resource is cached in the client, read the webpage resource from the client and load display;
  • the request initiating module 204 is configured to: when the webpage resource is not cached in the client, initiate a network request to the network server by using the OkHttp framework, so as to establish a data transmission pipeline flow between the web server and the client. ;
  • the loading cache module 205 is configured to synchronously load and display the currently read network resource data in the process of reading the network resource data returned by the data transmission pipeline flow, and simultaneously, the currently read network resource data. Synchronous caching.
  • the type of the webpage is HTML5.
  • the request initiating module 204 is specifically configured to:
  • the webpage resource is not cached in the client, determining whether the webpage resource belongs to a cache whitelist and a cached blacklist, wherein the cached whitelist has a first allowable resource cache a cache condition, the cache blacklist has a second cache condition that does not allow resource cache, and the first cache condition is different from the second cache condition;
  • the OkHttp framework is used to initiate a network request to the network server, so that a data transmission pipeline flow is established between the web server and the client. Otherwise, it returns empty and does not cache the web resource.
  • the determining module 203 includes:
  • the webpage resource address exists in the cache database, it indicates that the webpage resource is cached in the client. If the webpage resource address does not exist in the cache database, the webpage resource is not Cache in the client.
  • the device further comprises:
  • a storage module configured to acquire the cached data from the cache database, and store the cached data in a Map collection.
  • the method further comprises:
  • a time acquisition module configured to acquire a cache time of a webpage resource cached in the client
  • a period judging module configured to determine whether the cache time exceeds a preset cache period
  • the loading cache module is specifically configured to:
  • the webpage resource address corresponding to the currently read network resource data is synchronously cached into the cache database.
  • an embodiment of the present invention further provides a computer readable storage medium, where a computer program is stored, and when the program is executed by the processor, the following steps are implemented:
  • the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
  • the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
  • the embodiment of the invention further provides a computer device, as shown in FIG. 3, for convenience of explanation, only Portions related to the embodiments of the present invention are shown, and the specific technical details are not disclosed. Please refer to the method part of the embodiment of the present invention.
  • the computer device may be any terminal device including a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), an in-vehicle computer, and the like, and the computer device is used as a mobile phone as an example:
  • FIG. 3 is a block diagram showing a portion of the structure associated with a computer device provided by an embodiment of the present invention.
  • the computer device includes a memory 301 and a processor 302.
  • the computer device architecture illustrated in FIG. 3 does not constitute a limitation to a computer device, and may include more or fewer components than those illustrated, or some components may be combined, or different component arrangements.
  • the memory 301 can be used to store software programs and modules, and the processor 302 executes various functional applications and data processing by running software programs and modules stored in the memory 301.
  • the memory 301 can mainly include a storage program area and a storage data area, wherein the storage program area can store an operating system, an application required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area can store data. (such as audio data, phone book, etc.).
  • the memory 301 may include a high speed random access memory, and may also include a nonvolatile memory such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
  • the processor 302 is a control center of a computer device that performs various functions and processing data by running or executing software programs and/or modules stored in the memory 301, and recalling data stored in the memory 301.
  • the processor 302 may include one or more processing units; preferably, the processor 302 may integrate an application processor and a modem processor, where the application processor mainly processes an operating system, a user interface, an application, and the like.
  • the modem processor primarily handles wireless communications.
  • the processor 302 included in the computer device may have the following functions:
  • the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
  • the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
  • the present application is directed to an HTML webpage, in the process of loading an HTML webpage, first obtaining a webpage resource address, and then determining whether a webpage resource corresponding to the webpage resource address is cached locally on the client, if the webpage The page resource is cached locally on the client, and the webpage resource is read locally from the client and loaded and displayed. If the webpage resource is not cached locally on the client, the OkHttp framework is used to initiate a network request to the web server to enable the web server and the client.
  • the data transmission pipeline flow is established between the terminals, and in the process of the client reading the network resource data returned by the data transmission pipeline flow, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read The network resource data is synchronously cached.
  • This application only needs one network request to implement loading and buffering of uncached network resources, which improves the efficiency of loading cache and saves traffic. At the same time, the network request can be automatically filtered by using the OkHttp framework. Duplicate network requests
  • modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
  • the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
  • any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined.
  • Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
  • the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
  • a microprocessor or digital signal processor may be used in practice to implement some or all of the functionality of some, or all, of the gateways, proxy servers, systems in accordance with embodiments of the present invention.
  • the invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein.
  • a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.

Abstract

The invention relates to the technical field of application development, in particular to a hypertext markup language webpage loading method and device. The method comprises: acquiring a webpage resource address for a webpage based on the hypertext markup language (101); determining, according to the webpage resource address, whether webpage resources corresponding to the webpage resource address have been cached in a client (102); if the webpage resources have been cached in the client, reading the webpage resources from the client, and loading and displaying them; if the webpage resources have not been cached in the client, using OkHttp frame to issue a network request to a network server so that a data transmission duct stream is established between the network server and the client (103); in the process of reading network resource data returned by the data transmission duct stream, synchronously loading and displaying currently read network resource data, and synchronously caching the currently read network resource data (104). The method has the advantages that non-cached network sources can be loaded and cached just through a single network request, loading and caching efficiency is improved, and traffic is saved.

Description

超文本标记语言网页加载方法及装置Hypertext markup language webpage loading method and device 技术领域Technical field
本发明涉及应用开发技术领域,尤其涉及超文本标记语言网页加载方法及装置。The present invention relates to the field of application development technologies, and in particular, to a hypertext markup language webpage loading method and apparatus.
背景技术Background technique
超文本标记语言(HyperText Markup Language,HTML)是一种应用在网页中的标记语言,通过该标记语言能够实现网页的创建。针对利用HTML创建的网页而言,为了降低对物理数据源访问的频次,提高运行性能,这类网页在加载的同时将会被缓存。HyperText Markup Language (HTML) is a markup language applied to web pages, through which markup languages can be created. For web pages created with HTML, in order to reduce the frequency of access to physical data sources and improve running performance, such web pages will be cached while being loaded.
然而,现有技术在对HTML网页进行加载和缓存的过程中,需要向网络服务器发起两次网络请求,这两次网络请求分别为:用于网页加载的网络请求和用于网页缓存的网络请求,不仅存在加载缓存效率低的问题,而且还浪费流量。However, in the process of loading and caching an HTML webpage, the prior art needs to initiate two network requests to the web server, which are: a network request for webpage loading and a network request for webpage caching. Not only does the load cache have low efficiency, but it also wastes traffic.
发明内容Summary of the invention
鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的超文本标记语言网页加载方法及装置。In view of the above problems, the present invention has been made in order to provide a hypertext markup language web page loading method and apparatus that overcomes the above problems or at least partially solves the above problems.
本发明实施例提供一种超文本标记语言网页加载方法,应用于客户端中,所述方法包括:The embodiment of the invention provides a hypertext markup language webpage loading method, which is applied to a client, and the method includes:
针对基于超文本标记语言的网页而言,获取网页资源地址;For a webpage based on a hypertext markup language, obtaining a webpage resource address;
基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中;Determining, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client;
若所述网页资源已缓存在所述客户端中,则从所述客户端中读取所述网页资源并加载显示;If the webpage resource is already cached in the client, reading the webpage resource from the client and loading the display;
若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流;If the webpage resource is not cached in the client, the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
在读取所述数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存。During the process of reading the network resource data returned by the data transmission pipeline flow, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
优选的,所述网页的类型为HTML5。Preferably, the type of the webpage is HTML5.
优选的,所述若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流,包括: Preferably, if the webpage resource is not cached in the client, the OkHttp framework is used to initiate a network request to the network server, so that a data transmission pipeline flow is established between the web server and the client, including :
若所述网页资源未缓存在所述客户端中,则分别判断所述网页资源是否属于缓存白名单和缓存黑名单,其中,所述缓存白名单具有允许资源缓存的第一缓存条件,所述缓存黑名单内具有不允许资源缓存的第二缓存条件,所述第一缓存条件与第二缓存条件不同;If the webpage resource is not cached in the client, determining whether the webpage resource belongs to a cache whitelist and a cache blacklist, wherein the cache whitelist has a first cache condition that allows resource cache, Having a second cache condition in the cache blacklist that does not allow resource cache, the first cache condition being different from the second cache condition;
若所述网页资源属于所述缓存白名单且不属于所述缓存黑名单,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流,否则,返回空,不对所述网页资源进行缓存。If the webpage resource belongs to the cache whitelist and does not belong to the cache blacklist, the OkHttp framework is used to initiate a network request to the network server, so that a data transmission pipeline flow is established between the web server and the client. Otherwise, it returns empty and does not cache the web resource.
优选的,所述基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中,包括:Preferably, the determining, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client, includes:
在缓存数据库包含的缓存数据中查找是否存在所述网页资源地址;Finding whether the webpage resource address exists in the cache data included in the cache database;
其中,若所述缓存数据库中存在所述网页资源地址,则表明所述网页资源已缓存在所述客户端中,若所述缓存数据库中不存在所述网页资源地址,则所述网页资源未缓存在所述客户端中。If the webpage resource address exists in the cache database, it indicates that the webpage resource is cached in the client. If the webpage resource address does not exist in the cache database, the webpage resource is not Cache in the client.
优选的,在所述在缓存数据库包含的缓存数据中查找是否存在所述网页资源地址之前,所述方法还包括:Preferably, before the searching for the webpage resource address in the cache data included in the cache database, the method further includes:
从所述缓存数据库中获取所述缓存数据,并将所述缓存数据存放到Map集合中。Obtaining the cached data from the cache database and storing the cached data in a Map collection.
优选的.所述方法还包括:Preferably, the method further comprises:
获取缓存在所述客户端中的网页资源的缓存时间;Obtaining a cache time of a webpage resource cached in the client;
判断所述缓存时间是否超过预设缓存周期;Determining whether the cache time exceeds a preset cache period;
若所述缓存时间超过所述预设缓存周期,则对所述缓存在所述客户端中的网页资源进行删除。If the cache time exceeds the preset cache period, deleting the webpage resource cached in the client.
优选的,所述对当前读取到的网络资源数据进行同步缓存,包括:Preferably, the synchronizing the currently read network resource data, including:
将当前读取到的网络资源数据所对应的网页资源地址同步缓存到缓存数据库中。The webpage resource address corresponding to the currently read network resource data is synchronously cached into the cache database.
本发明实施例还提供一种超文本标记语言网页加载装置,所述装置包括:The embodiment of the invention further provides a hypertext markup language webpage loading device, the device comprising:
获取模块,用于针对基于超文本标记语言的网页而言,获取网页资源地址;An obtaining module, configured to obtain a webpage resource address for a webpage based on a hypertext markup language;
判断模块,用于基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中;a determining module, configured to determine, according to the webpage resource address, whether a webpage resource corresponding to the webpage resource address is cached in the client;
加载模块,用于若所述网页资源已缓存在所述客户端中,则从所述客户端中读取所述网页资源并加载显示;a loading module, configured to read the webpage resource from the client and load display if the webpage resource is already cached in the client;
请求发起模块,用于若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流; a request initiating module, if the webpage resource is not cached in the client, using a OkHttp framework to initiate a network request to the network server, so as to establish a data transmission pipeline flow between the web server and the client;
加载缓存模块,用于在读取所述数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存。Loading a cache module, configured to perform synchronous loading display on the currently read network resource data in the process of reading the network resource data returned by the data transmission pipeline flow, and simultaneously perform current read network resource data Synchronous cache.
本发明实施例还提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现以下步骤:The embodiment of the invention further provides a computer readable storage medium, on which a computer program is stored, and when the program is executed by the processor, the following steps are implemented:
针对基于超文本标记语言的网页而言,获取网页资源地址;For a webpage based on a hypertext markup language, obtaining a webpage resource address;
基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中;Determining, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client;
若所述网页资源已缓存在所述客户端中,则从所述客户端中读取所述网页资源并加载显示;If the webpage resource is already cached in the client, reading the webpage resource from the client and loading the display;
若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流;If the webpage resource is not cached in the client, the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
在读取所述数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存。During the process of reading the network resource data returned by the data transmission pipeline flow, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
本发明实施例还提供一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述程序时实现以下步骤:The embodiment of the invention further provides a computer device, comprising a memory, a processor and a computer program stored on the memory and operable on the processor, the processor implementing the program to implement the following steps:
针对基于超文本标记语言的网页而言,获取网页资源地址;For a webpage based on a hypertext markup language, obtaining a webpage resource address;
基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中;Determining, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client;
若所述网页资源已缓存在所述客户端中,则从所述客户端中读取所述网页资源并加载显示;If the webpage resource is already cached in the client, reading the webpage resource from the client and loading the display;
若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流;If the webpage resource is not cached in the client, the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
在读取所述数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存。During the process of reading the network resource data returned by the data transmission pipeline flow, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
本发明实施例中的一个或多个技术方案,至少具有如下技术效果或优点:One or more technical solutions in the embodiments of the present invention have at least the following technical effects or advantages:
本申请针对HTML网页,在加载HTML网页的过程中,先获取网页资源地址,接着判断网页资源地址对应的网页资源是否已缓存在客户端本地,若网页资源已缓存在客户端本地,则从客户端本地读取该网页资源并加载显示,若网页资源未缓存在客户端本地,则利用OkHttp框架向网络服务器发起网络请求,以使网络服务器和客户端之间建立数据传输管道流,并在客户端读取数据传输管道 流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存,本申请仅需要一次网络请求即可实现对未缓存的网络资源进行加载缓存,提高了加载缓存效率,节省了流量,同时由于利用OkHttp框架发起该网络请求,能够自动过滤掉重复的网络请求。The present application is directed to an HTML webpage. In the process of loading an HTML webpage, the webpage resource address is first obtained, and then the webpage resource corresponding to the webpage resource address is cached in the client locality. If the webpage resource is cached in the client locality, the client is from the client. The local end reads the webpage resource and loads the display. If the webpage resource is not cached locally on the client, the OkHttp framework is used to initiate a network request to the web server, so that a data transmission pipeline flow is established between the web server and the client, and the client Read data transmission pipeline In the process of streaming the returned network resource data, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached, and the application only needs one network request to implement the pair. Uncached network resources are loaded and cached, which improves the efficiency of loading caches and saves traffic. At the same time, due to the use of the OkHttp framework to initiate the network request, the repeated network requests can be automatically filtered out.
附图说明DRAWINGS
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考图形表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those skilled in the art from a The drawings are only for the purpose of illustrating the preferred embodiments and are not to be construed as limiting. Further, the same components are denoted by the same reference numerals throughout the drawings. In the drawing:
图1示出了本发明实施例中的一种超文本标记语言网页加载方法的流程图;FIG. 1 is a flowchart of a method for loading a hypertext markup language webpage in an embodiment of the present invention;
图2示出了本发明实施例中的一种超文本标记语言网页加载装置的结构图;2 is a structural diagram of a hypertext markup language webpage loading apparatus in an embodiment of the present invention;
图3示出了本发明实施例中的计算机设备的实体结构示意图。FIG. 3 is a schematic diagram showing the physical structure of a computer device in an embodiment of the present invention.
具体实施方式Detailed ways
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While the embodiments of the present invention have been shown in the drawings, the embodiments Rather, these embodiments are provided so that this disclosure will be more fully understood and the scope of the disclosure will be fully disclosed.
本申请实施例提供一种超文本标记语言网页加载方法,应用于客户端中,如图1所示,所述方法包括:The embodiment of the present application provides a hypertext markup language webpage loading method, which is applied to a client. As shown in FIG. 1, the method includes:
步骤101:针对基于超文本标记语言的网页而言,获取网页资源地址。Step 101: Obtain a webpage resource address for a webpage based on a hypertext markup language.
步骤102:基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中。Step 102: Determine, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client.
步骤103:若所述网页资源已缓存在所述客户端中,则从所述客户端中读取所述网页资源并加载显示;若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流。Step 103: If the webpage resource is already cached in the client, read the webpage resource from the client and load display; if the webpage resource is not cached in the client, use The OkHttp framework initiates a network request to the network server to establish a data transmission pipeline flow between the network server and the client.
步骤104:在读取所述数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存。 Step 104: During the process of reading the network resource data returned by the data transmission pipeline flow, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
本申请针对HTML网页,在加载HTML网页的过程中,先获取网页资源地址,接着判断网页资源地址对应的网页资源是否已缓存在客户端本地,若网页资源已缓存在客户端本地,则从客户端本地读取该网页资源并加载显示,若网页资源未缓存在客户端本地,则利用OkHttp框架向网络服务器发起网络请求,以使网络服务器和客户端之间建立数据传输管道流,并在客户端读取数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存,本申请仅需要一次网络请求即可实现对未缓存的网络资源进行加载缓存,提高了加载缓存效率,节省了流量,同时由于利用OkHttp框架发起该网络请求,能够自动过滤掉重复的网络请求。The present application is directed to an HTML webpage. In the process of loading an HTML webpage, the webpage resource address is first obtained, and then the webpage resource corresponding to the webpage resource address is cached in the client locality. If the webpage resource is cached in the client locality, the client is from the client. The local end reads the webpage resource and loads the display. If the webpage resource is not cached locally on the client, the OkHttp framework is used to initiate a network request to the web server, so that a data transmission pipeline flow is established between the web server and the client, and the client During the process of reading the network resource data returned by the data transmission pipeline flow, the network resource data currently read is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached, and the application only needs to be once. The network request can load and cache the uncached network resources, improve the efficiency of loading cache, save traffic, and automatically initiate filtering of duplicate network requests by using the OkHttp framework to initiate the network request.
在本申请中,网页的类型可以为HTML5。In this application, the type of the webpage may be HTML5.
本申请的方法可以建立在BasicWebViewClient类中,从而利用该BasicWebViewClient类替换现有技术中的WebViewClient,下面将对BasicWebViewClient类内部加载过程进行详细描述。The method of the present application can be established in the BasicWebViewClient class, thereby replacing the WebViewClient in the prior art by using the BasicWebViewClient class. The internal loading process of the BasicWebViewClient class is described in detail below.
针对步骤101而言,首先,可以通过shouldlnterceptRequest拦截待加载的网页中的网页资源地址(Uniform Resource Locator,URL),以实现对URL的获取,接着,执行步骤102。步骤102的一种优选的实施方式包括:For step 101, first, the page resource address (Uniform Resource Locator, URL) in the web page to be loaded may be intercepted by the shouldlnterceptRequest to obtain the URL, and then step 102 is performed. A preferred embodiment of step 102 includes:
在缓存数据库包含的缓存数据中查找是否存在所述网页资源地址。Finds whether the webpage resource address exists in the cache data contained in the cache database.
其中,缓存数据库位于客户端本地,缓存数据库中存储有已缓存过的缓存数据,缓存数据包括URL、缓存的网页资源以及两者之间的对应关系,例如,缓存数据库中包括URL1、URL1对应的第一图片、URL2和URL2对应的第二图片。本申请通过在缓存数据库包含的缓存数据中查找是否存在网页资源地址,能够确定与该网页资源地址对应的网页资源是否已被缓存在客户端本地,若缓存数据库包含的缓存数据中存在该网页资源地址,则表明该网页资源地址对应的网页资源已缓存在客户端本地,若缓存数据库包含的缓存数据中不存在该网页资源地址,则表明该网页资源地址对应的网页资源未缓存在客户端本地。The cache database is located locally on the client, and the cached database stores cached cache data. The cache data includes a URL, a cached webpage resource, and a correspondence between the two. For example, the cache database includes URL1 and URL1. The second picture corresponding to the first picture, URL2, and URL2. The present application can determine whether a webpage resource corresponding to the webpage resource address is cached in the client locality by searching whether the webpage resource address exists in the cache data included in the cache database, and if the webpage resource exists in the cached data included in the cache database. The address indicates that the webpage resource corresponding to the webpage resource address is cached locally on the client. If the webpage resource address does not exist in the cached data included in the cache database, the webpage resource corresponding to the webpage resource address is not cached locally on the client. .
本申请在执行在缓存数据库包含缓存数据中查找是否存在所述网页资源地址之前,还包括步骤:从所述缓存数据库中获取所述缓存数据,并将所述缓存数据存放到Map集合中。本申请通过将缓存数据从缓存数据库中提取出并存入Map集合中,避免了每次查找网页资源都需要调用缓存数据库所带来的查找效率低的问题。The present application further includes the steps of: obtaining the cached data from the cache database, and storing the cached data in a Map set, before performing the lookup of whether the webpage resource address exists in the cache database including the cache data. By extracting the cached data from the cache database and storing it in the Map collection, the present application avoids the problem of low search efficiency caused by calling the cache database every time the webpage resource is searched.
进一步,在步骤103中,若网页资源地址对应的网页资源已缓存在客户端本地,则,从客户端本地读取该网页资源并加载显示,若网页资源地址对应的网页资源未缓存在客户端本地,则利用OkHttp框架向网络服务器发起网络请 求,以使所述网络服务器和所述客户端之间建立数据传输管道流。Further, in step 103, if the webpage resource corresponding to the webpage resource address is cached locally on the client, the webpage resource is locally read from the client and loaded, and the webpage resource corresponding to the webpage resource address is not cached on the client. Local, use the OkHttp framework to launch a network to the web server. Soliciting a data transmission pipeline flow between the network server and the client.
在一种优选的实施方式中,所述若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流,包括:In a preferred implementation, if the webpage resource is not cached in the client, the OkHttp framework is used to initiate a network request to the network server to establish a connection between the web server and the client. Data transfer pipeline flow, including:
若所述网页资源未缓存在所述客户端中,则分别判断所述网页资源是否属于缓存白名单和缓存黑名单,其中,所述缓存白名单具有允许资源缓存的第一缓存条件,所述缓存黑名单内具有不允许资源缓存的第二缓存条件,所述第一缓存条件与第二缓存条件不同;If the webpage resource is not cached in the client, determining whether the webpage resource belongs to a cache whitelist and a cache blacklist, wherein the cache whitelist has a first cache condition that allows resource cache, Having a second cache condition in the cache blacklist that does not allow resource cache, the first cache condition being different from the second cache condition;
若所述网页资源属于所述缓存白名单且不属于所述缓存黑名单,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流,否则,返回空,不对所述网页资源进行缓存。If the webpage resource belongs to the cache whitelist and does not belong to the cache blacklist, the OkHttp framework is used to initiate a network request to the network server, so that a data transmission pipeline flow is established between the web server and the client. Otherwise, it returns empty and does not cache the web resource.
在具体实施过程中,若网页资源地址对应的网页资源未缓存在客户端本地,则判断该网页资源是否属于缓存白名单,同时判断该网页资源是否属于缓存黑名单,缓存白名单和缓存黑名单均可以是域名的集合,另外,缓存白名单具有第一缓存条件,缓存黑名单具有第二缓存条件,第一缓存条件和第二缓存条件不同。In a specific implementation process, if the webpage resource corresponding to the webpage resource address is not cached locally on the client, it is determined whether the webpage resource belongs to the cache whitelist, and whether the webpage resource belongs to the cached blacklist, the cached whitelist, and the cached blacklist. Each of the cached whitelists has a first cache condition, and the cached blacklist has a second cache condition, and the first cache condition and the second cache condition are different.
具体地,若网页资源属于缓存白名单且不属于缓存黑名单,则表明该网页资源具有缓存资格,若网页资源属于缓存黑名单,则表明该网页资源不具有缓存资格,若网页资源不属于缓存白名单也不属于缓存黑名单,则表明该网页资源不具有缓存资格。Specifically, if the webpage resource belongs to the cache whitelist and does not belong to the cache blacklist, it indicates that the webpage resource has the cache qualification. If the webpage resource belongs to the cached blacklist, it indicates that the webpage resource does not have the cache qualification, and if the webpage resource does not belong to the cache. The whitelist is also not a cached blacklist, indicating that the webpage resource is not eligible for caching.
例如,若缓存白名单中的第一缓存条件为域名为baidu,缓存黑名单中的第二缓存条件为后缀为JPG,而,第一网页资源的域名为baidu后缀为PNG,则第一网页资源具有缓存资格,利用OkHttp框架向网络服务器发起网络请求,第二网页资源的域名为baidu后缀为JPG,则第二网页资源不具有缓存资格,返回空,不对第二网页资源进行缓存,第三网页资源的域名为google后缀为PNG,则第三网页资源也不具有缓存资格,返回空,不对第二网页资源进行缓存。For example, if the first cache condition in the cache whitelist is the domain name baidu, the second cache condition in the cache blacklist is suffix JPG, and the domain name of the first webpage resource is baidu suffix PNG, the first webpage resource Having the cache qualification, using the OkHttp framework to initiate a network request to the network server, the domain name of the second webpage resource is baidu suffix is JPG, then the second webpage resource does not have the cache qualification, returns null, does not cache the second webpage resource, the third webpage If the domain name of the resource is google suffixed as PNG, the third webpage resource does not have the cache qualification, and returns null, and does not cache the second webpage resource.
进一步,本申请利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流,数据传输管道流包含输入管道流(PipedInputStream)和输出管道流(PipedOutputStream),本申请利用数据传输管道流实现主线程和子线程之间的直接通信,能够实现边下载边显示,具体地,在读取数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存,对于同步缓存的过程而言,本申请将当前读取到的网络资源数据所对应的网页资源地址同步缓存到缓存数据库中。在本申请中,数据管道流 中有多少数据,网页中就会显示多少内容,网页资源加载完,缓存数据也写入完毕,最后,将会把缓存好的缓存数据的路径以及存入时间写入缓存数据库中。Further, the present application utilizes the OkHttp framework to initiate a network request to the network server to establish a data transmission pipeline flow between the network server and the client, and the data transmission pipeline flow includes an input pipeline flow (PipedInputStream) and an output pipeline flow (PipedOutputStream). The present application utilizes the data transmission pipeline flow to implement direct communication between the main thread and the sub-thread, and can realize display while downloading, specifically, in the process of reading the network resource data returned by the data transmission pipeline flow, the current reading The obtained network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached. For the process of synchronous cache, the web resource address corresponding to the currently read network resource data is used in this application. Synchronous caching into the cache database. In this application, data pipeline flow How much data is in the webpage, how much content is displayed in the webpage, the webpage resource is loaded, and the cached data is also written. Finally, the cached cached data path and the deposit time are written into the cache database.
本申请的超文本标记语言网页加载方法还包括:The Hypertext Markup Language webpage loading method of the present application further includes:
获取缓存在所述客户端中的网页资源的缓存时间;Obtaining a cache time of a webpage resource cached in the client;
判断所述缓存时间是否超过预设缓存周期;Determining whether the cache time exceeds a preset cache period;
若所述缓存时间超过所述预设缓存周期,则对所述缓存在所述客户端中的网页资源进行删除。If the cache time exceeds the preset cache period, deleting the webpage resource cached in the client.
在具体实施过程中,缓存在客户端本地的网页资源的属性信息能够在数据库缓存列表中查找到,缓存在客户端本地的网页资源的缓存时间为存入时间与当前时间的差值,如果存入时间与当前时间的差值大于预设缓存周期,则将缓存在客户端本地的网页资源删除,如果缓存时间没有超过预设缓存周期,则继续保留,预设缓存周期可以设置为一天、一周或一个月。In the specific implementation process, the attribute information of the webpage resource cached locally on the client can be found in the database cache list, and the cache time of the webpage resource cached locally on the client is the difference between the deposit time and the current time. If the difference between the inbound time and the current time is greater than the preset cache period, the webpage resources cached on the client are deleted. If the cache time does not exceed the preset cache period, the reservation is continued. The preset cache period can be set to one day and one week. Or one month.
需要说明的是,本申请在获取URL之后,且在基于网页资源地址判断网页资源地址对应的网页资源是否已缓存在客户端本地之前,还包括方法:判断URL是否是正常的URL,若是,则执行后续加载缓存过程,若否,则直接返回空,不进行加载缓存过程。It should be noted that, after obtaining the URL, and determining whether the webpage resource corresponding to the webpage resource address is cached on the client locality based on the webpage resource address, the method further includes: determining whether the URL is a normal URL, and if yes, The subsequent loading cache process is executed. If not, it returns directly to the empty, and does not perform the load caching process.
基于同一发明构思,本发明实施例还提供一种超文本标记语言网页加载装置,如图2所示,所述装置包括:Based on the same inventive concept, an embodiment of the present invention further provides a hypertext markup language webpage loading device. As shown in FIG. 2, the device includes:
获取模块201,用于针对基于超文本标记语言的网页而言,获取网页资源地址;The obtaining module 201 is configured to obtain a webpage resource address for a webpage based on a hypertext markup language;
判断模块202,用于基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中;The determining module 202 is configured to determine, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client;
加载模块203,用于若所述网页资源已缓存在所述客户端中,则从所述客户端中读取所述网页资源并加载显示;The loading module 203 is configured to: if the webpage resource is cached in the client, read the webpage resource from the client and load display;
请求发起模块204,用于若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流;The request initiating module 204 is configured to: when the webpage resource is not cached in the client, initiate a network request to the network server by using the OkHttp framework, so as to establish a data transmission pipeline flow between the web server and the client. ;
加载缓存模块205,用于在读取所述数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存。The loading cache module 205 is configured to synchronously load and display the currently read network resource data in the process of reading the network resource data returned by the data transmission pipeline flow, and simultaneously, the currently read network resource data. Synchronous caching.
优选的,所述网页的类型为HTML5。Preferably, the type of the webpage is HTML5.
优选的,请求发起模块204,具体用于:Preferably, the request initiating module 204 is specifically configured to:
若所述网页资源未缓存在所述客户端中,则分别判断所述网页资源是否属于缓存白名单和缓存黑名单,其中,所述缓存白名单具有允许资源缓存的第一 缓存条件,所述缓存黑名单内具有不允许资源缓存的第二缓存条件,所述第一缓存条件与第二缓存条件不同;If the webpage resource is not cached in the client, determining whether the webpage resource belongs to a cache whitelist and a cached blacklist, wherein the cached whitelist has a first allowable resource cache a cache condition, the cache blacklist has a second cache condition that does not allow resource cache, and the first cache condition is different from the second cache condition;
若所述网页资源属于所述缓存白名单且不属于所述缓存黑名单,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流,否则,返回空,不对所述网页资源进行缓存。If the webpage resource belongs to the cache whitelist and does not belong to the cache blacklist, the OkHttp framework is used to initiate a network request to the network server, so that a data transmission pipeline flow is established between the web server and the client. Otherwise, it returns empty and does not cache the web resource.
优选的,判断模块203,包括:Preferably, the determining module 203 includes:
在缓存数据库包含的缓存数据中查找是否存在所述网页资源地址;Finding whether the webpage resource address exists in the cache data included in the cache database;
其中,若所述缓存数据库中存在所述网页资源地址,则表明所述网页资源已缓存在所述客户端中,若所述缓存数据库中不存在所述网页资源地址,则所述网页资源未缓存在所述客户端中。If the webpage resource address exists in the cache database, it indicates that the webpage resource is cached in the client. If the webpage resource address does not exist in the cache database, the webpage resource is not Cache in the client.
优选的,所述装置还包括:Preferably, the device further comprises:
存放模块,用于从所述缓存数据库中获取所述缓存数据,并将所述缓存数据存放到Map集合中。And a storage module, configured to acquire the cached data from the cache database, and store the cached data in a Map collection.
优选的.所述方法还包括:Preferably, the method further comprises:
时间获取模块,用于获取缓存在所述客户端中的网页资源的缓存时间;a time acquisition module, configured to acquire a cache time of a webpage resource cached in the client;
周期判断模块,用于判断所述缓存时间是否超过预设缓存周期;a period judging module, configured to determine whether the cache time exceeds a preset cache period;
删除模块,用于若所述缓存时间超过所述预设缓存周期,则对所述缓存在所述客户端中的网页资源进行删除。And deleting the module, if the cache time exceeds the preset cache period, deleting the webpage resource cached in the client.
优选的,所述加载缓存模块,具体用于:Preferably, the loading cache module is specifically configured to:
将当前读取到的网络资源数据所对应的网页资源地址同步缓存到缓存数据库中。The webpage resource address corresponding to the currently read network resource data is synchronously cached into the cache database.
基于同一发明构思,本发明实施例还提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现以下步骤:Based on the same inventive concept, an embodiment of the present invention further provides a computer readable storage medium, where a computer program is stored, and when the program is executed by the processor, the following steps are implemented:
针对基于超文本标记语言的网页而言,获取网页资源地址;For a webpage based on a hypertext markup language, obtaining a webpage resource address;
基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中;Determining, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client;
若所述网页资源已缓存在所述客户端中,则从所述客户端中读取所述网页资源并加载显示;If the webpage resource is already cached in the client, reading the webpage resource from the client and loading the display;
若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流;If the webpage resource is not cached in the client, the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
在读取所述数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存。During the process of reading the network resource data returned by the data transmission pipeline flow, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
本发明实施例还提供了一种计算机设备,如图3所示,为了便于说明,仅 示出了与本发明实施例相关的部分,具体技术细节未揭示的,请参照本发明实施例方法部分。该计算机设备可以为包括手机、平板电脑、PDA(Personal Digital Assistant,个人数字助理)、POS(Point of Sales,销售终端)、车载电脑等任意终端设备,以计算机设备为手机为例:The embodiment of the invention further provides a computer device, as shown in FIG. 3, for convenience of explanation, only Portions related to the embodiments of the present invention are shown, and the specific technical details are not disclosed. Please refer to the method part of the embodiment of the present invention. The computer device may be any terminal device including a mobile phone, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), an in-vehicle computer, and the like, and the computer device is used as a mobile phone as an example:
图3示出的是与本发明实施例提供的计算机设备相关的部分结构的框图。参考图3,该计算机设备包括:存储器301和处理器302。本领域技术人员可以理解,图3中示出的计算机设备结构并不构成对计算机设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。3 is a block diagram showing a portion of the structure associated with a computer device provided by an embodiment of the present invention. Referring to FIG. 3, the computer device includes a memory 301 and a processor 302. Those skilled in the art will appreciate that the computer device architecture illustrated in FIG. 3 does not constitute a limitation to a computer device, and may include more or fewer components than those illustrated, or some components may be combined, or different component arrangements.
下面结合图3对计算机设备的各个构成部件进行具体的介绍:The specific components of the computer device will be specifically described below with reference to FIG. 3:
存储器301可用于存储软件程序以及模块,处理器302通过运行存储在存储器301的软件程序以及模块,从而执行各种功能应用以及数据处理。存储器301可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储数据(比如音频数据、电话本等)等。此外,存储器301可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。The memory 301 can be used to store software programs and modules, and the processor 302 executes various functional applications and data processing by running software programs and modules stored in the memory 301. The memory 301 can mainly include a storage program area and a storage data area, wherein the storage program area can store an operating system, an application required for at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area can store data. (such as audio data, phone book, etc.). Further, the memory 301 may include a high speed random access memory, and may also include a nonvolatile memory such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
处理器302是计算机设备的控制中心,通过运行或执行存储在存储器301内的软件程序和/或模块,以及调用存储在存储器301内的数据,执行各种功能和处理数据。可选的,处理器302可包括一个或多个处理单元;优选的,处理器302可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。The processor 302 is a control center of a computer device that performs various functions and processing data by running or executing software programs and/or modules stored in the memory 301, and recalling data stored in the memory 301. Optionally, the processor 302 may include one or more processing units; preferably, the processor 302 may integrate an application processor and a modem processor, where the application processor mainly processes an operating system, a user interface, an application, and the like. The modem processor primarily handles wireless communications.
在本发明实施例中,该计算机设备所包括的处理器302可以具有以下功能:In the embodiment of the present invention, the processor 302 included in the computer device may have the following functions:
针对基于超文本标记语言的网页而言,获取网页资源地址;For a webpage based on a hypertext markup language, obtaining a webpage resource address;
基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中;Determining, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client;
若所述网页资源已缓存在所述客户端中,则从所述客户端中读取所述网页资源并加载显示;If the webpage resource is already cached in the client, reading the webpage resource from the client and loading the display;
若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流;If the webpage resource is not cached in the client, the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
在读取所述数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存。During the process of reading the network resource data returned by the data transmission pipeline flow, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
总之,本申请针对HTML网页,在加载HTML网页的过程中,先获取网页资源地址,接着判断网页资源地址对应的网页资源是否已缓存在客户端本地,若网 页资源已缓存在客户端本地,则从客户端本地读取该网页资源并加载显示,若网页资源未缓存在客户端本地,则利用OkHttp框架向网络服务器发起网络请求,以使网络服务器和客户端之间建立数据传输管道流,并在客户端读取数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存,本申请仅需要一次网络请求即可实现对未缓存的网络资源进行加载缓存,提高了加载缓存效率,节省了流量,同时由于利用OkHttp框架发起该网络请求,能够自动过滤掉重复的网络请求。In summary, the present application is directed to an HTML webpage, in the process of loading an HTML webpage, first obtaining a webpage resource address, and then determining whether a webpage resource corresponding to the webpage resource address is cached locally on the client, if the webpage The page resource is cached locally on the client, and the webpage resource is read locally from the client and loaded and displayed. If the webpage resource is not cached locally on the client, the OkHttp framework is used to initiate a network request to the web server to enable the web server and the client. The data transmission pipeline flow is established between the terminals, and in the process of the client reading the network resource data returned by the data transmission pipeline flow, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read The network resource data is synchronously cached. This application only needs one network request to implement loading and buffering of uncached network resources, which improves the efficiency of loading cache and saves traffic. At the same time, the network request can be automatically filtered by using the OkHttp framework. Duplicate network requests.
在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general purpose systems can also be used with the teaching based on the teachings herein. The structure required to construct such a system is apparent from the above description. Moreover, the invention is not directed to any particular programming language. It is to be understood that the invention may be embodied in a variety of programming language, and the description of the specific language has been described above in order to disclose the preferred embodiments of the invention.
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. However, it is understood that the embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques are not shown in detail so as not to obscure the understanding of the description.
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。Similarly, the various features of the invention are sometimes grouped together into a single embodiment, in the above description of the exemplary embodiments of the invention, Figure, or a description of it. However, the method disclosed is not to be interpreted as reflecting the intention that the claimed invention requires more features than those specifically recited in the claims. Rather, as the following claims reflect, inventive aspects reside in less than all features of the single embodiments disclosed herein. Therefore, the claims following the specific embodiments are hereby explicitly incorporated into the embodiments, and each of the claims as a separate embodiment of the invention.
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art will appreciate that the modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components. In addition to such features and/or at least some of the processes or units being mutually exclusive, any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined. Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
此外,本领域的技术人员能够理解,尽管在此的一些实施例包括其它实施 例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。Moreover, those skilled in the art will appreciate that although some embodiments herein include other implementations Some of the features are included in the examples and not in other features, but combinations of the features of the different embodiments are intended to be within the scope of the invention and the various embodiments. For example, in the following claims, any one of the claimed embodiments can be used in any combination.
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的网关、代理服务器、系统中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。The various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functionality of some, or all, of the gateways, proxy servers, systems in accordance with embodiments of the present invention. The invention can also be implemented as a device or device program (e.g., a computer program and a computer program product) for performing some or all of the methods described herein. Such a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。 It is to be noted that the above-described embodiments are illustrative of the invention and are not intended to be limiting, and that the invention may be devised without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as a limitation. The word "comprising" does not exclude the presence of the elements or steps that are not recited in the claims. The word "a" or "an" The invention can be implemented by means of hardware comprising several distinct elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means can be embodied by the same hardware item. The use of words, second, third, etc. does not indicate any order. These words can be interpreted as names.

Claims (10)

  1. 一种超文本标记语言网页加载方法,其特征在于,应用于客户端中,所述方法包括:A hypertext markup language webpage loading method is characterized in that it is applied to a client, and the method includes:
    针对基于超文本标记语言的网页而言,获取网页资源地址;For a webpage based on a hypertext markup language, obtaining a webpage resource address;
    基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中;Determining, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client;
    若所述网页资源已缓存在所述客户端中,则从所述客户端中读取所述网页资源并加载显示;If the webpage resource is already cached in the client, reading the webpage resource from the client and loading the display;
    若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流;If the webpage resource is not cached in the client, the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
    在读取所述数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存。During the process of reading the network resource data returned by the data transmission pipeline flow, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
  2. 如权利要求1所述的方法,其特征在于,所述网页的类型为HTML5。The method of claim 1 wherein the type of the web page is HTML5.
  3. 如权利要求1所述的方法,其特征在于,所述若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流,包括:The method according to claim 1, wherein if the webpage resource is not cached in the client, a network request is initiated to the web server by using the OkHttp framework, so that the web server and the client Establish a data transmission pipeline flow between the ends, including:
    若所述网页资源未缓存在所述客户端中,则分别判断所述网页资源是否属于缓存白名单和缓存黑名单,其中,所述缓存白名单具有允许资源缓存的第一缓存条件,所述缓存黑名单内具有不允许资源缓存的第二缓存条件,所述第一缓存条件与第二缓存条件不同;If the webpage resource is not cached in the client, determining whether the webpage resource belongs to a cache whitelist and a cache blacklist, wherein the cache whitelist has a first cache condition that allows resource cache, Having a second cache condition in the cache blacklist that does not allow resource cache, the first cache condition being different from the second cache condition;
    若所述网页资源属于所述缓存白名单且不属于所述缓存黑名单,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流,否则,返回空,不对所述网页资源进行缓存。If the webpage resource belongs to the cache whitelist and does not belong to the cache blacklist, the OkHttp framework is used to initiate a network request to the network server, so that a data transmission pipeline flow is established between the web server and the client. Otherwise, it returns empty and does not cache the web resource.
  4. 如权利要求1所述的方法,其特征在于,所述基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中,包括:The method of claim 1, wherein the determining, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client comprises:
    在缓存数据库包含的缓存数据中查找是否存在所述网页资源地址;Finding whether the webpage resource address exists in the cache data included in the cache database;
    其中,若所述缓存数据库中存在所述网页资源地址,则表明所述网页资源已缓存在所述客户端中,若所述缓存数据库中不存在所述网页资源地址,则所述网页资源未缓存在所述客户端中。If the webpage resource address exists in the cache database, it indicates that the webpage resource is cached in the client. If the webpage resource address does not exist in the cache database, the webpage resource is not Cache in the client.
  5. 如权利要求4所述的方法,其特征在于,在所述在缓存数据库包含的缓存数据中查找是否存在所述网页资源地址之前,所述方法还包括:The method of claim 4, wherein the method further comprises: before searching for the presence of the webpage resource address in the cache data included in the cache database, the method further comprising:
    从所述缓存数据库中获取所述缓存数据,并将所述缓存数据存放到Map集合中。 Obtaining the cached data from the cache database and storing the cached data in a Map collection.
  6. 如权利要求1所述的方法,其特征在于,所述方法还包括:The method of claim 1 wherein the method further comprises:
    获取缓存在所述客户端中的网页资源的缓存时间;Obtaining a cache time of a webpage resource cached in the client;
    判断所述缓存时间是否超过预设缓存周期;Determining whether the cache time exceeds a preset cache period;
    若所述缓存时间超过所述预设缓存周期,则对所述缓存在所述客户端中的网页资源进行删除。If the cache time exceeds the preset cache period, deleting the webpage resource cached in the client.
  7. 如权利要求1所述的方法,其特征在于,所述对当前读取到的网络资源数据进行同步缓存,包括:The method of claim 1, wherein the synchronizing the currently read network resource data comprises:
    将当前读取到的网络资源数据所对应的网页资源地址同步缓存到缓存数据库中。The webpage resource address corresponding to the currently read network resource data is synchronously cached into the cache database.
  8. 一种超文本标记语言网页加载装置,其特征在于,所述装置包括:A hypertext markup language webpage loading device, characterized in that the device comprises:
    获取模块,用于针对基于超文本标记语言的网页而言,获取网页资源地址;An obtaining module, configured to obtain a webpage resource address for a webpage based on a hypertext markup language;
    判断模块,用于基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中;a determining module, configured to determine, according to the webpage resource address, whether a webpage resource corresponding to the webpage resource address is cached in the client;
    加载模块,用于若所述网页资源已缓存在所述客户端中,则从所述客户端中读取所述网页资源并加载显示;a loading module, configured to read the webpage resource from the client and load display if the webpage resource is already cached in the client;
    请求发起模块,用于若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流;a request initiating module, if the webpage resource is not cached in the client, using a OkHttp framework to initiate a network request to the network server, so as to establish a data transmission pipeline flow between the web server and the client;
    加载缓存模块,用于在读取所述数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存。Loading a cache module, configured to perform synchronous loading display on the currently read network resource data in the process of reading the network resource data returned by the data transmission pipeline flow, and simultaneously perform current read network resource data Synchronous cache.
  9. 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,该程序被处理器执行时实现以下步骤:A computer readable storage medium having stored thereon a computer program, wherein the program, when executed by the processor, implements the following steps:
    针对基于超文本标记语言的网页而言,获取网页资源地址;For a webpage based on a hypertext markup language, obtaining a webpage resource address;
    基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中;Determining, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client;
    若所述网页资源已缓存在所述客户端中,则从所述客户端中读取所述网页资源并加载显示;If the webpage resource is already cached in the client, reading the webpage resource from the client and loading the display;
    若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流;If the webpage resource is not cached in the client, the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
    在读取所述数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存。During the process of reading the network resource data returned by the data transmission pipeline flow, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
  10. 一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理 器上运行的计算机程序,其特征在于,所述处理器执行所述程序时实现以下步骤:A computer device including a memory, a processor, and stored in a memory and capable of being processed A computer program running on the device, wherein the processor performs the following steps when executing the program:
    针对基于超文本标记语言的网页而言,获取网页资源地址;For a webpage based on a hypertext markup language, obtaining a webpage resource address;
    基于所述网页资源地址,判断所述网页资源地址对应的网页资源是否已缓存在所述客户端中;Determining, according to the webpage resource address, whether the webpage resource corresponding to the webpage resource address is cached in the client;
    若所述网页资源已缓存在所述客户端中,则从所述客户端中读取所述网页资源并加载显示;If the webpage resource is already cached in the client, reading the webpage resource from the client and loading the display;
    若所述网页资源未缓存在所述客户端中,则利用OkHttp框架向网络服务器发起网络请求,以使所述网络服务器和所述客户端之间建立数据传输管道流;If the webpage resource is not cached in the client, the network request is initiated to the network server by using the OkHttp framework, so that a data transmission pipeline flow is established between the web server and the client;
    在读取所述数据传输管道流返回的网络资源数据的过程中,对当前读取到的网络资源数据进行同步加载显示,同时,对当前读取到的网络资源数据进行同步缓存。 During the process of reading the network resource data returned by the data transmission pipeline flow, the currently read network resource data is synchronously loaded and displayed, and at the same time, the currently read network resource data is synchronously cached.
PCT/CN2017/107041 2017-06-27 2017-10-20 Hypertext markup language webpage loading method and device WO2019000722A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710499814.8 2017-06-27
CN201710499814.8A CN107291913B (en) 2017-06-27 2017-06-27 Hypertext markup language webpage loading method and device

Publications (1)

Publication Number Publication Date
WO2019000722A1 true WO2019000722A1 (en) 2019-01-03

Family

ID=60098192

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/107041 WO2019000722A1 (en) 2017-06-27 2017-10-20 Hypertext markup language webpage loading method and device

Country Status (2)

Country Link
CN (1) CN107291913B (en)
WO (1) WO2019000722A1 (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109992428B (en) * 2017-12-29 2022-06-07 北京京东尚科信息技术有限公司 Data processing method and system
CN109800370A (en) * 2018-12-14 2019-05-24 平安普惠企业管理有限公司 Display methods, device, computer equipment and the storage medium of Webpage
CN111035927A (en) * 2019-12-12 2020-04-21 珠海海鸟科技有限公司 Resource management method and device and readable storage medium
CN112214701A (en) * 2020-10-14 2021-01-12 青岛海尔科技有限公司 Page display method and system, storage medium and electronic device
CN113626740A (en) * 2021-06-30 2021-11-09 济南浪潮数据技术有限公司 Client data refreshing method, device and equipment
CN114827271A (en) * 2022-04-26 2022-07-29 土巴兔集团股份有限公司 Multi-level cache online control method and related device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103455478A (en) * 2012-05-21 2013-12-18 腾讯科技(深圳)有限公司 Webpage access accelerating method and device
CN105022750A (en) * 2014-04-28 2015-11-04 腾讯科技(北京)有限公司 Resource file loading method and apparatus
CN106022870A (en) * 2016-05-16 2016-10-12 南京邮电大学 Android purchase system based on geographical positional information
CN106055720A (en) * 2016-07-18 2016-10-26 北京小米移动软件有限公司 Webpage displaying method and device
CN106547833A (en) * 2016-10-11 2017-03-29 乐视控股(北京)有限公司 Web browser method and device
CN106790687A (en) * 2017-02-17 2017-05-31 和创(北京)科技股份有限公司 Webpage display method, web data processing method and server

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105760405A (en) * 2014-12-19 2016-07-13 阿里巴巴集团控股有限公司 Methods and devices for obtaining network resource for loading web page and method and device for caching network resource
CN104536849B (en) * 2015-01-20 2017-10-20 成都携恩科技有限公司 A kind of data back up method based on cloud computing
US20160344831A1 (en) * 2015-05-21 2016-11-24 Google Inc. Proxy service for content requests
US10505709B2 (en) * 2015-06-01 2019-12-10 Nxp B.V. White-box cryptography interleaved lookup tables
CN106354879A (en) * 2016-09-27 2017-01-25 北京奇虎科技有限公司 Webpage caching method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103455478A (en) * 2012-05-21 2013-12-18 腾讯科技(深圳)有限公司 Webpage access accelerating method and device
CN105022750A (en) * 2014-04-28 2015-11-04 腾讯科技(北京)有限公司 Resource file loading method and apparatus
CN106022870A (en) * 2016-05-16 2016-10-12 南京邮电大学 Android purchase system based on geographical positional information
CN106055720A (en) * 2016-07-18 2016-10-26 北京小米移动软件有限公司 Webpage displaying method and device
CN106547833A (en) * 2016-10-11 2017-03-29 乐视控股(北京)有限公司 Web browser method and device
CN106790687A (en) * 2017-02-17 2017-05-31 和创(北京)科技股份有限公司 Webpage display method, web data processing method and server

Also Published As

Publication number Publication date
CN107291913B (en) 2019-03-15
CN107291913A (en) 2017-10-24

Similar Documents

Publication Publication Date Title
WO2019000722A1 (en) Hypertext markup language webpage loading method and device
US9565265B2 (en) Method and apparatus for automatically optimizing the loading of images in a cloud-based proxy service
CN103218434B (en) A kind of method and apparatus loading static resource
CN110096660B (en) Method and device for loading page pictures and electronic equipment
CN103338249B (en) Caching method and device
US20100146415A1 (en) Dns prefetch
US20110289126A1 (en) Content delivery network
WO2015161658A1 (en) Webpage resource loading method and device
CN107197359B (en) Video file caching method and device
US11330075B2 (en) One-time cache
US10455047B2 (en) Methods and systems for application controlled pre-fetch
US8516041B1 (en) Pre-fetching asynchronously requested content
US20130111325A1 (en) Method and Apparatus of Processing Nested Fragment Caching of a Web Page
US20130346542A1 (en) Common web accessible data store for client side page processing
US9727524B2 (en) Remote direct memory access (RDMA) optimized high availability for in-memory data storage
WO2016173441A1 (en) Server cache processing method, apparatus and system
US20140006918A1 (en) Method and system for web page rearrangement
WO2017092364A1 (en) Advertisement data processing method and router
WO2015154682A1 (en) Network request processing method, network server, and network system
CN109325194B (en) Page access method, device, equipment and storage medium
US9160804B2 (en) Web storage optimization
CN109284428A (en) Data processing method, device and storage medium
CN112751917A (en) Resource file loading method, network device, electronic device and storage medium
US11379653B2 (en) Rendering method for on-demand loading of PDF file on network
KR101498920B1 (en) Web page pre-caching system and method for offline-executing

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17916248

Country of ref document: EP

Kind code of ref document: A1