CN108228818B - Webpage resource loading method and device, electronic equipment and storage medium - Google Patents

Webpage resource loading method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN108228818B
CN108228818B CN201711487474.3A CN201711487474A CN108228818B CN 108228818 B CN108228818 B CN 108228818B CN 201711487474 A CN201711487474 A CN 201711487474A CN 108228818 B CN108228818 B CN 108228818B
Authority
CN
China
Prior art keywords
webpage
resource
resources
path
local
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.)
Active
Application number
CN201711487474.3A
Other languages
Chinese (zh)
Other versions
CN108228818A (en
Inventor
张建伟
张平
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201711487474.3A priority Critical patent/CN108228818B/en
Publication of CN108228818A publication Critical patent/CN108228818A/en
Application granted granted Critical
Publication of CN108228818B publication Critical patent/CN108228818B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/972Access to data in other repository systems, e.g. legacy data or dynamic Web page generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading

Abstract

The invention provides a webpage resource loading method and device, electronic equipment and a storage medium, and relates to the technical field of data processing, wherein the webpage resource loading method comprises the following steps: acquiring webpage resources, and caching the webpage resources according to a directory organization structure of a relative path of the webpage resources; intercepting a webpage access request sent by a browser, and acquiring a relative path of the webpage access request; obtaining a local resource absolute path of the target webpage resource according to the relative path and a preset root path; and if the target webpage resource is determined to be cached in the local webpage resource according to the local resource absolute path, acquiring the target webpage resource and returning the target webpage resource to the browser. The method and the device can improve the experience of first access and no network access and reduce the network flow overhead; developers can accurately control cache resources; the mode of searching local resources by using a relative path is adopted, and the storage cost of mapping from the URL to the resources is not saved.

Description

Webpage resource loading method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of data processing, in particular to a webpage resource loading method, a webpage resource loading device, electronic equipment and a computer-readable storage medium.
Background
This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
In the prior art, when a browser is opened for accessing a certain webpage for the first time, if corresponding webpage resources are not cached locally, the webpage resources need to be requested to be loaded to a server, if no network exists, the corresponding webpage resources cannot be acquired, even if the network accesses for the first time, the speed is slow, and the user experience is reduced; secondly, the control force of a developer on the cache content of the browser is limited, and cache resources cannot be accurately managed and controlled; again, in the prior art, the browser cache needs to store the mapping relationship between the request link and the resource, and thus additional storage overhead is inevitably generated.
In view of the problems in the prior art, there is a need in the art to develop a web resource loading technique to improve the mobile browser page experience, speed up the page response speed, reduce unnecessary network traffic overhead, and reduce server pressure.
Disclosure of Invention
In the prior art, the application program adopting the native + HTML5 mixed mode is very common in the field of mobile development, the development cost of multiple operating systems can be reduced by using an HTML5 page, the online page is updated quickly, but the problems that the page access speed is slow for the first time, the cache resources and the network flow overhead cannot be managed and controlled accurately and the like still exist, and the user experience is reduced.
Therefore, a method for loading web page resources is needed, so that corresponding web page resources are directly obtained from cache resources during first access, the page access speed is improved, developers can accurately manage and control the cache resources, and unnecessary network traffic overhead is reduced.
In this context, embodiments of the present invention are intended to provide a web resource loading method, a web resource loading apparatus, an electronic device, and a computer-readable storage medium.
In a first aspect of an implementation method of the present invention, a method for loading a web resource is provided, including:
acquiring webpage resources, and caching the webpage resources according to a directory organization structure of a relative path of the webpage resources;
intercepting a webpage access request sent by a browser, and acquiring a relative path of the webpage access request;
obtaining a local resource absolute path of the target webpage resource according to the relative path and a preset root path;
and if the target webpage resource is determined to be cached in the local webpage resource according to the local resource absolute path, acquiring the target webpage resource and returning the target webpage resource to the browser.
In one embodiment of the invention, the web page access request includes a uniform resource identifier in the format "protocol name// domain name/relative path".
In one embodiment of the present invention, obtaining the relative path of the web page access request includes:
and intercepting the protocol name and the domain name of the uniform resource identifier to obtain a relative path of the webpage access request.
In one embodiment of the present invention, the preset root path corresponds to the domain name.
In one embodiment of the invention, the method further comprises:
and if the target webpage resource is determined not to be cached in the local webpage resource according to the local resource absolute path, acquiring the target webpage resource from a preset server through the webpage access request and returning the target webpage resource to the browser.
In an embodiment of the present invention, the browser is a built-in browser of an application, and an installation package of the application includes the web page resource; the acquiring of the webpage resources comprises:
and when the application program is installed, the webpage resources are obtained through the installation package of the application program.
In one embodiment of the invention, the browser is a built-in browser of an application program; the acquiring of the webpage resources comprises:
and after the application program is started, downloading the webpage resource from a preset server.
In one embodiment of the invention, the method further comprises:
and acquiring user input, and downloading, deleting, updating or inquiring the webpage resources according to the user input.
In a second aspect of the embodiments of the present invention, there is provided a web resource loading apparatus, including:
the webpage resource storage module is used for acquiring webpage resources and caching the webpage resources according to a directory organization structure of a relative path of the webpage resources;
the relative path acquisition module is used for intercepting a webpage access request sent by a browser and acquiring a relative path of the webpage access request;
the absolute path calculation module is used for obtaining a local resource absolute path of the target webpage resource according to the relative path and a preset root path;
and the webpage resource acquisition module is used for acquiring the target webpage resource and returning the target webpage resource to the browser when the target webpage resource is cached in the local webpage resource according to the local resource absolute path.
In an embodiment of the present invention, the browser is a built-in browser of an application, and an installation package of the application includes the web page resource; the device further comprises:
and the webpage resource acquisition module is used for acquiring the webpage resources through the installation package of the application program when the application program is installed.
In an embodiment of the present invention, the browser is a built-in browser of an application, and the apparatus further includes:
and the webpage resource downloading module is used for downloading the webpage resources from a preset server after the application program is started.
In one embodiment of the invention, the web page access request includes a uniform resource locator in the format "protocol name// domain name/relative path".
In one embodiment of the present invention, the relative path obtaining module includes:
and the path processing unit is used for intercepting the protocol name and the domain name in the uniform resource locator to form the relative path.
In one embodiment of the present invention, the preset root path corresponds to the domain name.
In an embodiment of the present invention, the web page resource obtaining module is further configured to, when it is determined that the target web page resource is not included in the cached local web page resources, obtain the target web page resource from a preset server through the web page access request and return the target web page resource to the browser.
In one embodiment of the invention, the apparatus further comprises:
and the webpage resource control module is used for acquiring user input and downloading, deleting, updating or inquiring the local webpage resources according to the user input.
In a third aspect of embodiments of the present invention, there is provided an electronic apparatus comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to execute the above-mentioned web resource loading method via executing the executable instructions.
In a fourth aspect of the embodiments of the present invention, there is provided a computer-readable storage medium on which a computer program is stored, the computer program, when executed by a processor, implementing the above-mentioned web resource loading method.
According to the webpage resource loading method and the webpage resource loading device, the webpage resources can be cached according to the directory organization structure of the relative path of the webpage resources, the relative path is obtained according to the webpage access request, the absolute path of the local resources is calculated, whether the corresponding webpage resources exist in the webpage resources cached to the local according to the absolute path of the local resources is searched, and if the corresponding webpage resources exist, the target webpage resources are obtained and returned to the browser. By the device and the method, on one hand, the webpage resources can be cached locally in advance, when a first webpage access request exists, the target webpage resources can be obtained from the local cache resources and returned to the browser, further, the target webpage can be opened under the condition of no network, the webpage access speed and the user experience are improved, and under the condition of the network, the first access speed of the webpage is improved; on the other hand, as the webpage resources are cached locally, developers can accurately manage and control the cached resources; in addition, the local cache resource retrieval is carried out by adopting a relative path matching mode, so that extra storage cost is not required, and the storage space is saved.
Drawings
The above and other objects, features and advantages of exemplary embodiments of the present invention will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the invention are illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which:
FIG. 1 schematically illustrates a flow diagram of a method for loading web page resources according to an embodiment of the invention;
FIG. 2 schematically illustrates a resource path diagram according to an embodiment of the invention;
FIG. 3 is a diagram schematically illustrating a local cache resource directory structure according to an embodiment of the present invention;
FIG. 4 is a flow diagram that schematically illustrates a method for loading web page resources, in accordance with an embodiment of the present invention;
FIG. 5 is a flow chart of a method for loading web page resources according to an embodiment of the invention;
FIG. 6 is a schematic diagram illustrating a web resource loading apparatus according to an embodiment of the present invention;
FIG. 7 schematically illustrates an electronic device for web resource loading, in accordance with an embodiment of the present invention; and
FIG. 8 schematically illustrates a program product for web page resource loading according to an embodiment of the present invention.
In the drawings, the same or corresponding reference numerals indicate the same or corresponding parts.
Detailed Description
The principles and spirit of the present invention will be described with reference to a number of exemplary embodiments. It is understood that these embodiments are given solely for the purpose of enabling those skilled in the art to better understand and to practice the invention, and are not intended to limit the scope of the invention in any way. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
As will be appreciated by one skilled in the art, embodiments of the present invention may be embodied as a system, apparatus, device, method, or computer program product. Accordingly, the present disclosure may be embodied in the form of: entirely hardware, entirely software (including firmware, resident software, micro-code, etc.), or a combination of hardware and software.
According to the embodiment of the invention, a webpage resource loading method and a webpage resource loading device are provided.
In this document, any number of elements in the drawings is by way of example and not by way of limitation, and any nomenclature is used solely for differentiation and not by way of limitation.
The principles and spirit of the present invention are explained in detail below with reference to several representative embodiments of the invention.
Summary of The Invention
The inventor finds that, in the prior art, a browser is opened for the first time to access a webpage corresponding to a certain URL (Uniform Resource identifier), and since no corresponding cache Resource exists locally, a request for loading a webpage Resource is required, so that the corresponding Resource cannot be acquired when the webpage is accessed for the first time under the condition of no network, and even under the condition of the network, the speed of the network for accessing the webpage for the first time is affected by the network bandwidth; after a page is accessed for the first time, the browser caches acquired webpage resources, cache control can be performed on the cache of the browser through an HTTP (hyper text transport protocol) protocol in the prior art, but when the cache space of the browser is full, a local cache can be cleaned by the browser, so that whether the local cache exists and is available or not can not be guaranteed even if the cache is performed, and developers cannot accurately control the cache resources of the browser; meanwhile, the browser cache needs to store the mapping relationship between the request URL and the resource, which results in extra storage overhead.
Based on the above, the basic idea of the invention is: acquiring webpage resources and caching the webpage resources to the local according to a preset path; intercepting a webpage access request sent by a browser, and acquiring a resource relative path of the webpage access request; obtaining a local resource absolute path of the target webpage resource according to the relative path and the root path; and if the target webpage resource is determined to be cached in the local webpage resource according to the local resource absolute path, acquiring the target webpage resource and returning the target webpage resource to the browser. Therefore, according to the embodiment of the invention, the webpage resources can be cached locally according to the preset path, the relative path of the webpage resource access request is obtained, the local resource absolute path is calculated, whether the corresponding webpage resources exist in the webpage resources cached locally is searched through the local resource absolute path, and if the corresponding webpage resources exist, the target webpage resources are obtained and returned to the browser. Therefore, the webpage resources are cached locally according to the preset path, the first access speed can be improved, the user experience of the browser is improved, unnecessary network flow expenditure of a user is reduced, developers can accurately control the cached resources, and meanwhile, additional storage expenditure for storing the mapping relation between the URL and the resources is avoided.
Having described the general principles of the invention, various non-limiting embodiments of the invention are described in detail below.
Exemplary method
The method for loading the web resource in the present invention is applicable to application scenarios of mobile terminals such as notebook computers and smart phones, and the method for loading the web resource according to the exemplary embodiment of the present invention is described with reference to fig. 1. It should be noted that the above application scenarios are merely illustrated for the convenience of understanding the spirit and principles of the present invention, and the embodiments of the present invention are not limited in this respect. Rather, embodiments of the present invention may be applied to any scenario where applicable.
FIG. 1 is a flowchart illustrating a method for loading web page resources according to an embodiment of the present invention. Referring to fig. 1, the method for loading web page resources may include the following steps:
step S10: acquiring webpage resources, and caching the webpage resources according to a directory organization structure of a relative path of the webpage resources;
step S30: intercepting a webpage access request sent by a browser, and acquiring a relative path of the webpage access request;
step S50: obtaining a local resource absolute path of the target webpage resource according to the relative path and a preset root path;
step S70: and if the target webpage resource is determined to be cached in the local webpage resource according to the local resource absolute path, acquiring the target webpage resource and returning the target webpage resource to the browser.
By caching the webpage resources to the local according to the preset path, the first access speed can be improved, the user experience of the browser can be improved, the unnecessary network flow expenditure of a user can be reduced, developers can accurately control the cached resources, and the additional storage expenditure for storing the mapping relation between the URL and the resources is avoided.
Next, the web page resource loading method in the present exemplary embodiment will be further explained.
In step S10, a web resource may be obtained through a terminal, and the web resource is cached according to a directory organization structure of a relative path of the web resource.
In the present exemplary embodiment, the terminal may be used for input of user information, output of a processing result, and the like; the terminal may be a notebook computer, a mobile phone, a Pad, etc., and in this exemplary embodiment, the step is described with the mobile phone as the terminal; the webpage resources are basic elements forming the website and are platforms for bearing various website applications; local refers to a computer directly connected to the user, or to a device or process under the direct control of the user, as opposed to a remote host, device, and process.
The terminal in this example embodiment may be installed with a browser to render the web resource content. The mobile phone is provided with an application program, the webpage resources can be preloaded through the application program and cached locally according to the relative path of the URL, and the URL corresponding to the webpage resources cached locally is http:// domain name/relative path of the resources. Fig. 2 shows a resource path, as shown in fig. 2, resource includes primary directory html, js and css, where the primary directory html includes secondary directories a.html and b.html, the primary directory js includes secondary directories a.js and b.js, the primary directory css includes secondary directories a.css and b.css, if a web resource is cached to the secondary directory a.html, the corresponding access URL is http:// domain name/resource/html/a.html, if a web resource is cached to the secondary directory b.css, the corresponding access URL is http:// domain name/resource/css/b.css, and when a web resource is cached locally according to other paths, the corresponding access URL format is similar to the above access URL format, except that the adaptability of the relative path is changed. The resource path may also be other paths as long as the web page resource can be cached locally and has a corresponding URL.
In an embodiment of the present invention, the browser may be a built-in browser of an application, the web resource folder may be packaged into an installation package as a resource package, and the local cache is available after the application is successfully installed. That is, the web page resource may be obtained through an installation package of the application when the application is installed.
In another embodiment of the present invention, the browser may be a built-in browser of the application, but the web resource is not packaged into the application, but after the application is successfully installed, the web resource is downloaded to the local via the network after the application is started or before the page is accessed, that is, the web resource is downloaded from a preset server. Of course, the web page resource may also be downloaded to the local through the network at other occasions after the application program is successfully installed, which is not specifically limited in the present invention.
The webpage resources are downloaded to the local through the network, the webpage resources can be directly obtained by a terminal request from a server side, or a difference file can be obtained by the server side request, and then the difference file and the local webpage cache resources of the terminal are combined and calculated to obtain the corresponding webpage resources and cached to the local. For example, the terminal stores a webpage cache resource folder a, and the corresponding webpage cache resource compression packet is p (a); the server side stores a difference file Diff (AB) of the webpage cache resource folder A and a webpage resource folder B, wherein the difference file Diff (AB) comprises difference information of relative paths of a plurality of webpage resources in the webpage resource folder B and a plurality of webpage resources in the webpage cache resource folder A; the terminal requests the server to download the difference file Diff (AB), and combines the webpage cache resource compression packet P (A) and the difference file Diff (AB) stored in the terminal to obtain a webpage cache resource new version compression packet P (B), and then decompresses P (B) to obtain a webpage resource folder B, wherein the webpage resource folder B comprises a plurality of webpage resources and corresponding relative path information; and finally, storing the plurality of webpage resources in the webpage resource folder B under a preset root directory according to the corresponding relative paths to form local cache resources.
Further, the preset root directory may correspond to a domain name in the URL, for example, a root path of the web page resource cached locally may be named CacheRootPath, and together with the resource path, a local directory organization structure of the web page cache resource is formed, such as the local directory organization structure of the web page cache resource formed by the root path CacheRootPath shown in fig. 3 and the resource path shown in fig. 2. Those skilled in the art will appreciate that the CacheRootPath is only an exemplary designation in this application and that other designations for the root path are possible.
In step S30, a web page access request sent by a browser is intercepted, and a relative path of the web page access request is obtained.
This step is described herein by taking an example in which the terminal mounts the iOS operating system and the Android operating system. In both the iOS and the Android systems, there are services capable of intercepting a web access request URL sent by a browser, for example, an iOS operating system may obtain the web access request URL using an NSURLProtocol service, and an Android operating system may obtain the web access request URL using a WebViewClient service. Of course, the operating system may also use other programs to obtain the URL of the web page access request, which is not described herein again. In addition, in the exemplary embodiment, an iOS operating system and an Android operating system are taken as examples for description, but the disclosure is not limited thereto, and for example, the method in the disclosure is also applicable to other operating systems such as Windows.
In this example embodiment, after intercepting the URL corresponding to the web page access request, the protocol name and the domain name in the URL may be intercepted to obtain the relative path of the web page access request. For example, if the URL corresponding to the webpage access request is http:// domain name/resource/html/a.html, intercepting the protocol name and the domain name therein to obtain a path "resource/html/a.html", which is the relative path of the webpage access request; if the URL corresponding to the webpage access request is http:// domain name/resource/html/b.css, intercepting the protocol name and the domain name therein to obtain a path 'resource/html/b.css', namely the relative path of the webpage access request. It should be understood by those skilled in the art that the above examples are not intended to limit the relative path in the present application, and other web page access request URL interception protocol names and domain names may be used to obtain corresponding relative paths.
In step S50, a local resource absolute path of the target web page resource is obtained according to the relative path and the preset root path.
The relative path refers to the path relationship with other files (or folders) caused by the path where the current file is located; the local resource absolute path refers to a disk access full path of a local cache file.
In this example embodiment, the absolute path of the local web page cache resource may be obtained by calculation according to the root path of the web page cache resource and the URL relative path, and the corresponding calculation formula is: the absolute path is a webpage resource cache root path CacheRootPath + relative path, and taking the relative path as "resource/html/a.html" as an example, the absolute path of the corresponding local webpage cache resource is "CacheRootPath/resource/html/a.html", and whether the target webpage resource exists in the local cache resource can be queried according to the absolute path; taking the relative path as "resource/html/b.css" as an example, the absolute path of the corresponding local webpage cache resource is "CacheRootPath/resource/html/b.css", and whether the target webpage resource exists in the local cache resource can be queried according to the absolute path.
In this example embodiment, the preset root path may correspond to a domain name in the web page access request URL. If the relative paths under different domain names are the same and the corresponding webpage resources are the same, the different domain names correspond to the same preset root path; if the relative paths under different domain names are different and the corresponding web page resources are different, the different domain names correspond to different preset root paths.
In step S70, if it is determined that the target web resource is in the web resource cached locally according to the local resource absolute path, the target web resource is obtained and returned to the browser
In the present exemplary embodiment, the absolute path of the local web page cache resource is obtained through step S50, and therefore, whether the target web page resource exists in the web page resource cached to the local can be queried according to the absolute path. Fig. 4 shows a specific flow of the web resource loading method in the present invention, as shown in fig. 4, if a target web resource exists in the web resources cached to the local, the target web resource is obtained, an HTTP response is generated, the response is returned to the browser, the target web resource is rendered in the browser, and corresponding web content is presented; if not, continuing to send the network request to acquire the webpage resource, acquiring the target webpage resource from a preset server, returning the target webpage resource to the browser, and rendering and presenting the corresponding webpage content in the browser.
In this example embodiment, a dual memory cache manner may also be adopted to speed up the cache resource mapping. The dual memory cache mode maintains two parts in the memory cache, namely a first part of the memory cache1 and a second part of the memory cache2, the first part of the memory cache1 caches the mapping from the URL to the local resource absolute path, and the second part of the memory cache2 caches the mapping from the web resource data and the local resource absolute path to the web resource data. The specific webpage resource loading method is shown in fig. 5:
s501: intercepting a webpage access request sent by a browser, and acquiring a webpage access request URL;
s502: searching a corresponding local resource absolute path in the MemoryCache1 according to the webpage access request URL; if yes, jumping to S504; if not, continuing to S503;
s503: calculating a local absolute path of a webpage resource according to the webpage access request URL, and storing the mapping from the webpage access request URL to the absolute path to the MemoryCache 1;
s504: searching corresponding webpage cache resource data in the MemoryCache2 according to the local absolute path of the webpage cache resource; if yes, jumping to S506; if not, continuing to S505;
s505: reading the disk file according to the local absolute path of the webpage cache resource, reading the webpage cache resource data to the MemoryCache2, and storing the mapping from the local absolute path of the webpage cache resource to the cache resource data to the MemoryCache 2;
s506: and generating a response according to the webpage cache resource data, returning the response to the browser, and rendering and presenting the corresponding webpage content in the browser.
By adopting the dual memory cache, the cache resource mapping can be accelerated, the calculation speed from the URL to the corresponding webpage cache resource is increased, the first opening speed of the webpage is increased, the webpage can still be accessed under the condition of no network, and the user experience is improved.
In this exemplary embodiment, by caching the web page resource on the local file system of the application program, the web page cache resource can be operated like operating the local file to control downloading, deleting, updating, and querying of the web page cache resource, so as to achieve accurate control of the web page cache resource. And local cache resource retrieval is carried out through the relative path matching mode, the mapping relation between the URL and the webpage resource is not required to be saved, and the additional storage expense of the mapping relation between the URL and the resource is not saved.
Exemplary device
Having described the method of the exemplary embodiment of the present invention, a web resource loading apparatus 600 of an exemplary embodiment of the present invention is described in detail with reference to fig. 6. As shown in fig. 6, the web resource loading device may include: a web resource storage module 601, a relative path acquisition module 602, an absolute path calculation module 603, and a web resource acquisition module 604. Wherein:
the web page resource storage module 601 is used for acquiring web page resources and caching the web page resources according to a directory organization structure of a relative path;
a relative path obtaining module 602, configured to intercept a web page access request sent by a browser, and obtain a relative path of the web page access request;
an absolute path calculation module 603, configured to obtain a local resource absolute path of the target web resource according to the relative path and a preset root path;
the web resource obtaining module 604 may be configured to, when it is determined that the target web resource is cached in the local web resource according to the local resource absolute path, obtain the target web resource and return the target web resource to the browser.
In an embodiment of the present invention, the relative path obtaining module 602 may include:
and the path processing unit can be used for intercepting the protocol name and the domain name in the uniform resource locator to form the relative path.
In the present exemplary embodiment, the web page access request includes a URL in the format of "protocol name// domain name/relative path", and the web page access request is intercepted by the path processing unit. And the preset root path corresponds to the domain name in the webpage access request.
In an embodiment of the present invention, the browser is a built-in browser of an application, and an installation package of the application includes a web resource, and the web resource loading apparatus 600 may further include:
and the webpage resource acquisition module is used for acquiring the webpage resources through the installation package of the application program when the application program is installed.
In an embodiment of the present invention, the browser is a built-in browser of an application, and the installation package of the application does not include web resources, and the web resource loading apparatus 600 may further include:
and the webpage resource downloading module is used for downloading the webpage resources from a preset server after the application program is started.
In an embodiment of the present invention, the web page resource obtaining module may be further configured to, when it is determined that the target web page resource is not included in the web page resources cached locally, obtain the target web page resource from a preset server through a web page access request and return the target web page resource to the browser.
In an embodiment of the present invention, the web resource loading apparatus 600 further includes:
and the webpage resource control module is used for acquiring user input and downloading, deleting, updating or inquiring the local webpage resources according to the user input.
Exemplary device
Having described the method and apparatus of an exemplary embodiment of the present invention, an electronic device for web page resource loading according to another exemplary embodiment of the present invention is described next.
As will be appreciated by one skilled in the art, aspects of the present invention may be embodied as a system, method or program product. Thus, various aspects of the invention may be embodied in the form of: an entirely hardware embodiment, an entirely software embodiment (including firmware, microcode, etc.) or an embodiment combining hardware and software aspects that may all generally be referred to herein as a "circuit," module "or" system.
In some possible embodiments, an electronic device according to the invention may comprise at least one processing unit, and at least one memory unit. Wherein the storage unit stores program code which, when executed by the processing unit, causes the processing unit to perform the steps in the web resource loading method according to various exemplary embodiments of the present invention described in the above section "exemplary method" of this specification. For example, the processing unit may execute step S10 as shown in fig. 1: acquiring webpage resources, and caching the webpage resources according to a directory organization structure of a relative path of the webpage resources; s20: intercepting a webpage access request sent by a browser, and acquiring a relative path of the webpage access request; s30: obtaining a local resource absolute path of the target webpage resource according to the relative path and a preset root path; s40: and if the target webpage resource is determined to be cached in the local webpage resource according to the local resource absolute path, acquiring the target webpage resource and returning the target webpage resource to the browser.
An electronic device 700 for spatial localization according to this embodiment of the present invention is described below with reference to fig. 7. The electronic device 700 shown in fig. 7 is only an example and should not bring any limitation to the function and the scope of use of the embodiments of the present invention.
As shown in fig. 7, the electronic device 700 is embodied in a general purpose computing device. The components of the electronic device 700 may include, but are not limited to: the at least one processing unit 701, the at least one memory unit 702, and a bus 703 that couples various system components including the memory unit 702 and the processing unit 701.
Bus 703 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures.
The storage unit 702 can include readable media in the form of volatile memory, such as Random Access Memory (RAM)7021 and/or cache memory 7022, and can further include Read Only Memory (ROM) 7023.
Storage unit 702 may also include a program/utility 7025 having a set (at least one) of program modules 7024, such program modules 7024 including, but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may comprise an implementation of a network environment.
The electronic device 700 may also communicate with one or more external devices 704 (e.g., keyboard, pointing device, bluetooth device, etc.), with one or more devices that enable a user to interact with the electronic device 700, and/or with any devices (e.g., router, modem, etc.) that enable the electronic device 700 to communicate with one or more other computing devices. Such communication may occur via input/output (I/O) interfaces 705. Also, the electronic device 700 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network such as the Internet) via the network adapter 706. As shown, the network adapter 706 communicates with the other modules of the electronic device 700 over a bus 703. It should be appreciated that although not shown in FIG. 7, other hardware and/or software modules may be used in conjunction with electronic device 700, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
Exemplary program product
In some possible embodiments, aspects of the present invention may also be implemented in a form of a program product including program code for causing a terminal device to perform the steps in the web resource loading method according to various exemplary embodiments of the present invention described in the above section "exemplary method" of this specification when the program product is run on the terminal device, for example, the processing unit may perform the step S10 shown in fig. 1: acquiring webpage resources, and caching the webpage resources according to a directory organization structure of a relative path of the webpage resources; s20: intercepting a webpage access request sent by a browser, and acquiring a relative path of the webpage access request; s30: obtaining a local resource absolute path of the target webpage resource according to the relative path and a preset root path; s40: and if the target webpage resource is determined to be cached in the local webpage resource according to the local resource absolute path, acquiring the target webpage resource and returning the target webpage resource to the browser.
The program product may employ any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
As shown in fig. 8, a program product 800 for spatial localization according to an embodiment of the present invention is depicted, which may employ a portable compact disc read only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited in this regard and, in the present document, a readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A readable signal medium may include a propagated data signal with readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A readable signal medium may also be any readable medium that is not a readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device over any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computing device (e.g., over the internet using an internet service provider).
It should be noted that although in the above detailed description several means or sub-means for spatially positioned electronic devices are mentioned, this division is only not mandatory. Indeed, the features and functions of two or more of the devices described above may be embodied in one device, according to embodiments of the invention. Conversely, the features and functions of one apparatus described above may be further divided into embodiments by a plurality of apparatuses.
Moreover, while the operations of the method of the invention are depicted in the drawings in a particular order, this does not require or imply that the operations must be performed in this particular order, or that all of the illustrated operations must be performed, to achieve desirable results. Additionally or alternatively, certain steps may be omitted, multiple steps combined into one step execution, and/or one step broken down into multiple step executions.
While the spirit and principles of the invention have been described with reference to several particular embodiments, it is to be understood that the invention is not limited to the disclosed embodiments, nor is the division of aspects, which is for convenience only as the features in such aspects may not be combined to benefit. The invention is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.

Claims (14)

1. A webpage resource loading method is characterized by comprising the following steps:
acquiring webpage resources, and caching the webpage resources according to a directory organization structure of a relative path of the webpage resources; and caching the resource mapping by using a double-caching mode, wherein the resource mapping comprises the following steps: caching the mapping from the uniform resource identifier to the local resource absolute path in the first part, and caching the mapping from the webpage resource data and the local resource absolute path to the webpage resource data in the second part;
intercepting a webpage access request sent by a browser, and acquiring a relative path of the webpage access request; the webpage access request comprises a uniform resource identifier with a format of protocol name// domain name/relative path;
searching in the first part according to the relative path of the webpage access request and a preset root path to obtain a local resource absolute path of the target webpage resource; the preset root path corresponds to the domain name of the webpage access request;
and if the target webpage resource is searched in the second part according to the local resource absolute path and is determined to be cached in the local webpage resource, acquiring the target webpage resource and returning to the browser.
2. The method for loading webpage resources of claim 1, wherein obtaining the relative path of the webpage access request comprises:
and intercepting the protocol name and the domain name of the uniform resource identifier to obtain a relative path of the webpage access request.
3. The method for loading webpage resources according to claim 1, further comprising:
and if the target webpage resource is determined not to be cached in the local webpage resource according to the local resource absolute path, acquiring the target webpage resource from a preset server through the webpage access request and returning the target webpage resource to the browser.
4. The method for loading webpage resources of claim 1, wherein the browser is a built-in browser of an application program, and the installation package of the application program includes the webpage resources; the acquiring of the webpage resources comprises:
and when the application program is installed, the webpage resources are obtained through the installation package of the application program.
5. The method for loading webpage resources of claim 1, wherein the browser is a built-in browser of an application program; the acquiring of the webpage resources comprises:
and after the application program is started, downloading the webpage resource from a preset server.
6. The method for loading webpage resources according to any one of claims 1-5, wherein the method further comprises:
and acquiring user input, and downloading, deleting, updating or inquiring the webpage resources according to the user input.
7. A web resource loading apparatus, comprising:
the webpage resource storage module is used for acquiring webpage resources and caching the webpage resources according to a directory organization structure of a relative path of the webpage resources; and caching the resource mapping by using a double-caching mode, wherein the resource mapping comprises the following steps: caching the mapping from the uniform resource identifier to the local resource absolute path in the first part, and caching the mapping from the webpage resource data and the local resource absolute path to the webpage resource data in the second part;
the relative path acquisition module is used for intercepting a webpage access request sent by a browser and acquiring a relative path of the webpage access request; the webpage access request comprises a uniform resource identifier with a format of protocol name// domain name/relative path;
the absolute path calculation module is used for searching in the first part according to the relative path of the webpage access request and a preset root path to obtain a local resource absolute path of the target webpage resource; the preset root path corresponds to the domain name of the webpage access request;
and the webpage resource acquisition module is used for acquiring the target webpage resource and returning the target webpage resource to the browser if the target webpage resource is searched and determined in the second part according to the local resource absolute path and cached to the local webpage resource.
8. The apparatus for loading web page resources according to claim 7, wherein the browser is a built-in browser of an application program, and the installation package of the application program includes the web page resources; the device further comprises:
and the webpage resource acquisition module is used for acquiring the webpage resources through the installation package of the application program when the application program is installed.
9. The web page resource loading apparatus according to claim 7, wherein the browser is a built-in browser of an application program, the apparatus further comprising:
and the webpage resource downloading module is used for downloading the webpage resources from a preset server after the application program is started.
10. The web page resource loading device according to claim 7, wherein the relative path obtaining module comprises:
and the path processing unit is used for intercepting the protocol name and the domain name in the uniform resource locator to form the relative path.
11. The device for loading web page resources according to claim 7, wherein the web page resource obtaining module is further configured to, when it is determined that the target web page resource is not included in the cached local web page resources, obtain the target web page resource from a preset server through the web page access request and return the target web page resource to the browser.
12. The web page resource loading apparatus according to any one of claims 7 to 11, wherein the apparatus further comprises:
and the webpage resource control module is used for acquiring user input and downloading, deleting, updating or inquiring the local webpage resources according to the user input.
13. An electronic device, comprising:
a processor; and
a memory for storing executable instructions of the processor;
wherein the processor is configured to perform the web page resource loading method of any one of claims 1 to 6 via execution of the executable instructions.
14. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the web resource loading method of any one of claims 1 to 6.
CN201711487474.3A 2017-12-29 2017-12-29 Webpage resource loading method and device, electronic equipment and storage medium Active CN108228818B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711487474.3A CN108228818B (en) 2017-12-29 2017-12-29 Webpage resource loading method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711487474.3A CN108228818B (en) 2017-12-29 2017-12-29 Webpage resource loading method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN108228818A CN108228818A (en) 2018-06-29
CN108228818B true CN108228818B (en) 2021-01-12

Family

ID=62646504

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711487474.3A Active CN108228818B (en) 2017-12-29 2017-12-29 Webpage resource loading method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN108228818B (en)

Families Citing this family (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108228818B (en) * 2017-12-29 2021-01-12 网易(杭州)网络有限公司 Webpage resource loading method and device, electronic equipment and storage medium
CN108932332A (en) * 2018-07-05 2018-12-04 麒麟合盛网络技术股份有限公司 The loading method and device of static resource
CN108875086B (en) * 2018-07-18 2023-03-28 山东中创软件商用中间件股份有限公司 Matching method and system of URI path resources
CN109088764B (en) * 2018-08-15 2022-04-22 郑州悉知信息科技股份有限公司 Access request processing method and related equipment
CN109582889A (en) * 2018-10-17 2019-04-05 平安普惠企业管理有限公司 Picture loading method, device, computer equipment and storage medium
CN109800370A (en) * 2018-12-14 2019-05-24 平安普惠企业管理有限公司 Display methods, device, computer equipment and the storage medium of Webpage
CN109992737A (en) * 2019-04-03 2019-07-09 北京字节跳动网络技术有限公司 Third party's web page contents checking method, device and electronic equipment
CN110555184A (en) * 2019-09-06 2019-12-10 深圳市珍爱捷云信息技术有限公司 resource caching method and device, computer equipment and storage medium
CN110795650A (en) * 2019-09-18 2020-02-14 平安银行股份有限公司 Webpage opening method and device and computer readable storage medium
CN111124539B (en) * 2019-12-20 2023-08-15 腾讯科技(深圳)有限公司 Initial scene resource file searching method, device, equipment and storage medium
CN111314426A (en) * 2020-01-17 2020-06-19 北京达佳互联信息技术有限公司 Webpage resource obtaining method and device, electronic equipment and storage medium
CN111666497B (en) * 2020-06-16 2023-06-06 腾讯科技(上海)有限公司 Application program loading method and device, electronic equipment and readable storage medium
CN111931083B (en) * 2020-06-30 2023-07-25 北京奇艺世纪科技有限公司 Webpage loading method and device, terminal equipment and readable storage medium
CN112040340A (en) * 2020-08-25 2020-12-04 海信电子科技(深圳)有限公司 Resource file acquisition method and display device
CN112632425B (en) * 2020-12-10 2024-02-06 京东科技控股股份有限公司 Method, device, equipment and storage medium for generating offline resource file
CN112507259A (en) * 2020-12-15 2021-03-16 广州博冠信息科技有限公司 Webpage loading method and device, electronic equipment and storage medium
CN112559927B (en) * 2020-12-23 2023-01-03 上海哔哩哔哩科技有限公司 Webpage loading method and device
CN113065079B (en) * 2021-04-13 2023-10-13 开鑫金服(南京)信息服务有限公司 Method, equipment and storage medium for realizing calling of native page based on address protocol
CN113271362B (en) * 2021-06-08 2022-10-11 天闻数媒科技(湖南)有限公司 Education resource processing method, device, system and medium based on hybrid cloud
CN113392346B (en) * 2021-06-16 2023-09-12 北京豆萌信息技术有限公司 Path processing method and device for resource file, electronic equipment and storage medium
CN113452808B (en) * 2021-06-29 2023-06-23 百果园技术(新加坡)有限公司 Domain name resolution method, device, equipment and storage medium
CN113626741A (en) * 2021-07-02 2021-11-09 杭州隆埠科技有限公司 Method and equipment for loading webpage of mobile client
CN113656739A (en) * 2021-09-03 2021-11-16 中国联合网络通信集团有限公司 Website data storage method and device
CN114221953A (en) * 2021-11-29 2022-03-22 平安证券股份有限公司 Resource acquisition method, device, equipment and storage medium
CN114422491B (en) * 2021-12-20 2024-01-30 福州佳软软件技术有限公司 Method and terminal for improving page acquisition efficiency

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105530543A (en) * 2014-09-28 2016-04-27 深圳Tcl新技术有限公司 Method and device for browser automatic webpage resource downloading
CN107203555A (en) * 2016-03-17 2017-09-26 阿里巴巴集团控股有限公司 Page loading processing method and device
CN108228818A (en) * 2017-12-29 2018-06-29 网易(杭州)网络有限公司 Web page resources loading method and device, electronic equipment and storage medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7930327B2 (en) * 2007-05-21 2011-04-19 International Business Machines Corporation Method and apparatus for obtaining the absolute path name of an open file system object from its file descriptor

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105530543A (en) * 2014-09-28 2016-04-27 深圳Tcl新技术有限公司 Method and device for browser automatic webpage resource downloading
CN107203555A (en) * 2016-03-17 2017-09-26 阿里巴巴集团控股有限公司 Page loading processing method and device
CN108228818A (en) * 2017-12-29 2018-06-29 网易(杭州)网络有限公司 Web page resources loading method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN108228818A (en) 2018-06-29

Similar Documents

Publication Publication Date Title
CN108228818B (en) Webpage resource loading method and device, electronic equipment and storage medium
RU2673403C2 (en) Website access method, device and website system
KR102294326B1 (en) Prefetching application data for periods of disconnectivity
US9825812B2 (en) Transparently intercepting and optimizing resource requests
US9235451B2 (en) Browser kernel switching method
US11061863B2 (en) Method and apparatus for opening file, and electronic device
CN110062043B (en) Service management method, service management device, storage medium, and electronic device
US8612418B2 (en) Mobile web browser for pre-loading web pages
US9244702B1 (en) Installer-free applications using native code modules and persistent local storage
CN107635027B (en) Domain name resolution method, medium, device and computing equipment
US20060129635A1 (en) Method of displaying data of a client computer
US20080147671A1 (en) System for Running Web Applications Offline and Providing Access to Native Services
US20140208326A1 (en) File presenting method and apparatus for a smart terminal
CN108256014B (en) Page display method and device
US20170017380A1 (en) Mobile enabling a web application developed without mobile rendering capabilities
EP3304293B1 (en) Code caching system
US9164817B2 (en) Mobile communication terminal to provide widget expansion function using message communication, and operation method of the mobile communication terminal
CN104978378A (en) Webpage access method and device
CN111783005A (en) Method, apparatus and system for displaying web page, computer system and medium
US20140129666A1 (en) Preemptive caching of data
CN110851194A (en) Method and device for acquiring code for realizing new interface
EP3001311A1 (en) Method for automatically converting web applications into application that can be installed automatically on a plurality of platforms
US10990750B2 (en) Dynamically bundling web page resources
US9098228B2 (en) Determining content rendering capabilities for web browser optimization
CN107045549B (en) Method and device for acquiring page number of electronic book

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
GR01 Patent grant
GR01 Patent grant