CN105095280B - Browser caching method and device - Google Patents

Browser caching method and device Download PDF

Info

Publication number
CN105095280B
CN105095280B CN201410201879.6A CN201410201879A CN105095280B CN 105095280 B CN105095280 B CN 105095280B CN 201410201879 A CN201410201879 A CN 201410201879A CN 105095280 B CN105095280 B CN 105095280B
Authority
CN
China
Prior art keywords
page
browser
webpage
server
cached
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
CN201410201879.6A
Other languages
Chinese (zh)
Other versions
CN105095280A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201410201879.6A priority Critical patent/CN105095280B/en
Publication of CN105095280A publication Critical patent/CN105095280A/en
Application granted granted Critical
Publication of CN105095280B publication Critical patent/CN105095280B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a browser caching method and a browser caching device.A browser acquires a first page when opening the page for the first time, triggers a page loading completion event after loading the page attribute in the first page, and executes an initialization request for a second page in the page loading completion event; acquiring a second page through the initialization request, and caching the second page to the local; and when the webpage is opened again, acquiring the first page, triggering a page loading completion event after loading the webpage attribute in the first page, and reading the cached second page.

Description

Browser caching method and device
Technical Field
The invention relates to the internet caching technology, in particular to a browser caching method and device.
Background
In a high-concurrency and high-flow system, a front-end page is often required to be cached, at present, solutions such as a flash memory (flash) and a local storage (localstorage) are roughly provided for front-end caching on a webpage (web) side, and in the implementation process, the problems of complex implementation, storage upper limit and browser support exist in the existing solutions.
Disclosure of Invention
In order to solve the existing technical problem, embodiments of the present invention mainly provide a browser caching method and device.
The technical scheme of the embodiment of the invention is realized as follows:
the embodiment of the invention provides a browser caching method, which comprises the following steps:
the method comprises the steps that when a browser opens a webpage for the first time, a first page is obtained, after webpage attributes in the first page are loaded, a page loading completion event is triggered, and an initialization request for a second page is executed in the page loading completion event;
acquiring a second page through the initialization request, and caching the second page to the local;
and when the webpage is opened again, acquiring the first page, triggering a page loading completion event after loading the webpage attribute in the first page, and reading the cached second page.
The embodiment of the invention also provides a browser caching method, which comprises the following steps:
the server sends the first page to the browser when receiving a first page request of the browser, and sends the second page to the browser after receiving an initialization request of the browser for the second page.
An embodiment of the present invention further provides a terminal, where the terminal includes: a browser and a memory; wherein the content of the first and second substances,
the browser is used for acquiring a first page when the webpage is opened for the first time, triggering a page loading completion event after the webpage attribute in the first page is loaded, and executing an initialization request for a second page in the page loading completion event; acquiring a second page through the initialization request, and caching the second page to a memory; when the webpage is opened again, the first page is obtained, after the webpage attribute in the first page is loaded, a page loading completion event is triggered, and a second page cached in the memory is read;
and the memory is used for caching the second page acquired by the browser.
An embodiment of the present invention further provides a server, where the server includes: the device comprises a first page sending module and a second page sending module; wherein the content of the first and second substances,
the first page sending module is used for sending a first page to the browser when receiving a first page request of the browser;
and the first page sending module is used for sending the second page to the browser after receiving an initialization request of the browser for the second page.
The embodiment of the invention also provides a browser caching system, which comprises the terminal and the server.
The invention provides a browser caching method and device, wherein when a browser opens a webpage for the first time, the browser acquires a first page, triggers a page loading completion event after loading webpage attributes in the first page, and executes an initialization request for a second page in the page loading completion event; acquiring a second page through the initialization request, and caching the second page to the local; when the webpage is opened again, the first page is obtained, after the webpage attribute in the first page is loaded, a page loading completion event is triggered, and a cached second page is read; therefore, the mode of caching the page separately has no influence on the original service code, can support most mainstream browsers, is simple to implement, can effectively reduce requests and network flow in the refreshing process, and has absolute advantage in high-concurrency and high-flow scenes.
Drawings
FIG. 1 is a diagram illustrating the overhead detection of F5 refresh page in the prior art;
FIG. 2 is a diagram illustrating the relationship between the click refresh (F5 or Ctrl + F5) process and onload event execution process of Chrome browser or safari browser in the prior art;
FIG. 3 is a diagram illustrating the relationship between the click refresh (F5 or Ctrl + F5) process and onload event execution process of IE browser in the prior art;
fig. 4 is a schematic flowchart of a method for implementing browser caching on a terminal side according to an embodiment of the present invention;
FIG. 5 is a schematic diagram illustrating a webpage display after loading a webpage attribute in a frame page according to an embodiment of the present invention;
FIG. 6 is a schematic diagram illustrating a webpage display after loading and rendering a content page according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of a terminal according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a server according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a browser caching system according to an embodiment of the present invention.
Detailed Description
Currently, most browsers generally cache an opened webpage in a local cache directory, and when a webpage is opened next time, the cached webpage is read in the local cache directory. Typically, the browser determines that the read cache is associated with 3 fields:
Last-Modified: the last modification time of the file on the server;
expires: in a local cache directory, file expiration time;
cache-control specifying the caching mechanism to which requests and responses follow, typically the expiration specified by the server
And the browser generates specific failure time according to the time interval.
When the browser requests server resources, if the Cache time and the Cache-control value of the file in the Cache directory are valid, the browser does not send out an HTTP request, but directly reads the local file in the local Cache directory.
The browser requests server resources can be divided into the following 3 cases:
1) directly clicking a link or inputting url access in an address bar;
in this case, the browser determines whether to read the Cache content by means of Expires and Cache-control.
2) Click F5 to refresh the page;
in this case, the browser ignores the Expires and the Cache-control, adds an if-Modified-site parameter to a header file of the HTTP resource request sent to the server, the value is Last-Modified time of the Last request, the server determines whether the if-Modified-site parameter matches the Last Modified time of the web page on the server, if so, returns a message 304, the browser directly reads the cached web page after receiving the message 304, and if not, returns the content of the web page, and the browser receives the content of the web page.
3) Clicking Ctrl + F5 to refresh the page;
the browser ignores Expires, Cache-Control and Last-modified time, adds Pragma: no-Cache or Pragma: no-Cache to a header file of an HTTP resource request sent to the server, and directly requests the server to return webpage content, wherein the Cache-Control: max-age: 0.
Comparing the above 3 cases, the overhead of the browser to read the cache is as follows:
1) direct access to the links: the HTTP resource request is not sent, the cache is directly read, and the overhead is minimum;
2) f5 refresh page: as shown in FIG. 1, sending out about 500Bytes of byte traffic, receiving 150-200 Bytes of byte traffic, in the case of a cookie, the HTTP resource request will carry the cookie, and the HTTP resource request will be larger than that in the case of no cookie shown in FIG. 1, but when F5 refreshes the page, the overhead is generally smaller, however, the process of creating the HTTP resource request will affect the page rendering speed.
3) Ctrl + F5 refreshes the page: all resources of the webpage request the server, and the cost is the largest.
Taking the test data of a certain commodity in the commodity detail webpage as an example:
1) direct access: the browser receives 114.5 kb;
2) f5 refresh: the browser receives 171.4 kb;
3) ctrl + F5 refresh: the browser receives 1550.9 kb.
Compared with the data under the condition of starting gzip acceleration, it can be seen that if the page can directly access the cache file no matter F5 refresh or Ctrl + F5 refresh, the traffic pressure of background services and Content Delivery Networks (CDN) is greatly reduced, and the performance of the website can be greatly improved in some high concurrency occasions (such as Tanbao 11, the CDN traffic reaches 400G/s).
The click refresh (F5 or Ctrl + F5) process and onload event execution process of different browsers are tested in the following two cases:
in the Chrome browser or safari browser, as shown in fig. 2, the flow is as follows:
step 201: the user clicks F5 or Ctrl + F5;
step 202: the browser receives a message that a user clicks F5 or Ctrl + F5, and opens a refreshing state;
step 203: the browser sends an HTTP resource request to the server;
step 204: the server returns 304 a message or web page resource;
step 205: the browser loads a webpage and renders the webpage;
in this step, if the server returns a 304 message, the browser reads the webpage resources from the local cache directory to load, and renders the page; and if the server returns the webpage resources, the browser directly loads the webpage according to the webpage resources and renders the webpage.
Step 206: the browser closes the refresh state;
step 207: the browser triggers an onload event.
In the IE-series browser, as shown in fig. 3, the flow is as follows:
step 301: the user clicks F5 or Ctrl + F5;
step 302: the browser receives a message that a user clicks F5 or Ctrl + F5, and opens a refreshing state;
step 303: the browser sends an HTTP resource request to the server;
step 304: the server returns 304 a message or web page resource;
step 305: the browser loads a webpage and renders the webpage;
in this step, if the server returns a 304 message, the browser reads the webpage resources from the local cache directory to load, and renders the page; and if the server returns the webpage resources, the browser directly loads the webpage according to the webpage resources and renders the webpage.
Step 306: the browser triggers onload event;
step 307: the browser closes the refresh state.
It can be seen that in the IE-series browser, the browser triggers the onload event before the browser closes the refresh state, in the Chrome browser or safari browser, and the browser triggers the onload event after the browser closes the refresh state, in both cases, in the user refresh process, the browser needs to send an HTTP resource request to the server, which increases traffic overhead, and is not favorable for website refresh performance in high-concurrency situations.
In the embodiment of the invention, when a browser opens a webpage for the first time, the browser acquires a first page, triggers a page loading completion event after loading the webpage attribute in the first page, and executes an initialization request for a second page in the page loading completion event; acquiring a second page through the initialization request, and caching the second page to the local; and directly reading the cached second page after the webpage is opened again and the page loading completion event is triggered. Here, the first page may be referred to as a frame page, and includes a web page attribute and a page load completion event, where the web page attribute includes: a Cascading Style Sheet (CSS) tag, a JS (javascript) tag and the like, wherein the CSS tag is generally a CSS outsink request, and the JS tag is generally a JS outsink request; the page loading completion event is generally an onload event; the initialization request comprises a page initialization object request and a static resource request; the second page may be referred to as a content page, and includes web page content such as an HTML object, and/or a CSS object, and/or a JS object, and/or a picture of the web page, where the HTML object may be an HTML document, the CSS object may be a CSS document, and the JS object may be a JS document.
In addition, the first page and the second page need to be deployed under the same domain name, and the second page can be obtained by being pulled in an ajax get mode.
The invention is further described in detail below with reference to the figures and the specific embodiments.
The embodiment of the invention realizes a browser caching method, and on a terminal side, as shown in fig. 4, the method mainly comprises the following steps:
step 401: the method comprises the steps that when a browser opens a webpage for the first time, a frame page is obtained;
here, the frame page includes: webpage attribute and webpage loading completion event; when a webpage is opened by a browser, whether cache content of the webpage exists is searched locally, such as a link address, an icon and the like, when the cache content of the webpage does not exist, the webpage is determined to be opened for the first time, then a frame page request is sent to a server to acquire the frame page, the server can return the frame page and the version number of the webpage, and the browser can determine whether the cache can be read according to the version number, for example: when the returned version number is consistent with the version number in the cache, the cache content can be read, and when the returned version number is inconsistent with the version number in the cache, the cache content is not read.
In this embodiment, when configuring a web page in advance, the web page needs to be split into a frame page and a content page for respective configuration, and the size of the frame page needs to be as small as possible, that is, the frame page only includes content that does not need to be cached and a page loading completion event, so that when reopening the web page, the overhead of the requested frame page is small; and the content pages are all the content that can be cached, such as: HTML object, CSS object, JS object, picture, etc.
Step 402: after the browser loads the webpage attributes in the frame page, triggering a page loading completion event, and executing an initialization request for the content page in the page loading completion event;
wherein, the loading the page attributes in the frame page may include: and reading the CSS label and/or the JS label, acquiring the CSS outer chain content according to the CSS outer chain request when the CSS label is the CSS outer chain request, and acquiring the JS outer chain content according to the JS outer chain request when the JS label is the JS outer chain request, wherein the webpage loaded with the webpage attribute can display the CSS outer chain content and/or the JS outer chain content as shown in fig. 5.
In this step, the specifically performing the initialization request for the content page in the page load completion event is: adding a set delay time (setTimeout) event into a page loading completion event in advance, wherein the set delay time can be determined according to the time for reading a cache by a browser and can be generally set to 1ms or 2ms, executing the set delay time event after triggering the page loading completion event, inquiring whether a cached content page exists or not locally within the delay time, and if not, sending an initialization request for the content page to a server after the delay time is up; if yes, the cached content page is directly read, and the initialization request for the content page is not sent after the delay time. Here, since the web page is opened for the first time and the content page is not cached locally, the initialization request for the content page is transmitted to the server after the delay time has elapsed.
Wherein the initialization request for the content page comprises a content page initialization object request and a static resource request.
Step 403: the browser acquires a content page through the initialization request, loads and renders the content page, and caches the content page to the local;
wherein the loading and rendering the content page comprises: arranging webpage contents such as HTML (hypertext markup language) objects, CSS (cascading style sheets) objects, JS (Java script) objects and pictures of webpages included in content pages according to the formats of the webpages, and rendering according to parameters of the webpage contents, wherein the parameters comprise: color, font size, etc.; the HTML object can be an HTML document, the CSS object can be a CSS document, and the JS object can be a JS document; as shown in FIG. 6, the web page opened by the browser after loading and rendering the content page will display all of the content page, including HTML objects, and/or CSS objects, and/or JS objects, and/or pictures, etc.
The browser may also cache the version number of the web page together with the corresponding content page to a local, where the local is generally a local cache directory.
Step 404: when the webpage is refreshed by clicking F5 or Ctrl + F5, the browser acquires a frame page, and after the webpage attributes in the frame page are loaded, a page loading completion event is triggered, and the cached content page is read;
here, since the content page is already cached locally in step 403, after the browser triggers the page load completion event, in the process of executing the set delay time event, since the trigger page load completion event marks that the refresh is completed, the browser will read the local cache content, and can read the cached content page.
In the above embodiment, a caching mode in which the frame page and the content page are separated is used, original service codes in a webpage are not affected, most of mainstream browsers can be supported, the implementation is simple, when F5 or Ctrl + F5 is clicked to refresh the webpage, an HTTP resource request is not required to be sent to a server, and a response message returned by the server is not required to be received, so that a request and network traffic in a refresh process can be effectively reduced, and the method has an absolute advantage in a high-concurrency and high-traffic scene.
In another example, the browser may determine to update the cached content page based on the version number of the web page returned by the server not being consistent with the version number in the cache. Specifically, the browser may compare whether the version number of the web page returned by the server is consistent with the version number in the cache in the process of executing the delay time setting event, and when the version number is inconsistent, the browser does not read the cached content page, but sends an initialization request for the content page to the server after the delay time expires, acquires the content page through the initialization request for the content page, loads and renders the content page, and then caches a new content page to cover the local original content page.
Then if the content page retrieved by the initialisation request for the content page is wrong, the cached content page will also be a wrong page, and then it will not read a wrong content page every time the page is re-opened? In order to solve this problem, the browser according to the embodiment of the present invention may further set the initial value (inited) in the cookie of the content page to false (false) when the content page is acquired, and set the inited to true (true) after the content page is completely loaded and cached (tube), so that when the browser reads the locally cached content page, the inited may be read first, if the inited is tube, the cached content page may be read, and if the false is, the cached content page may not be read, and it is necessary to send an initialization request for the content page to the server after the delay time expires, and acquire the content page through the initialization request for the content page.
In another embodiment of the present invention, a browser caching method is implemented, where, on a server side, the method mainly includes: the server sends the first page to the browser when receiving a first page request of the browser, and sends the second page to the browser after receiving an initialization request of the browser for the second page. Here, the first page may be referred to as a frame page, and includes a web page attribute and a page load completion event, where the web page attribute includes: the system comprises a CSS label, a JS label and the like, wherein the CSS label is generally a CSS external chain request, and the JS label is generally a JS external chain request; the initialization request comprises a page initialization object request and a static resource request; the second page may be referred to as a content page, and includes web page content such as an HTML object, and/or a CSS object, and/or a JS object, and/or a picture of the web page, where the HTML object may be an HTML document, the CSS object may be a CSS document, and the JS object may be a JS document.
In order to implement the above method, the present invention further provides a terminal, as shown in fig. 7, where the terminal includes: a browser 71 and a memory 72; the browser 71 is configured to obtain a first page when a web page is opened for the first time, trigger a page loading completion event after loading a web page attribute in the first page, and execute an initialization request for a second page in the page loading completion event; acquiring a second page through the initialization request, and caching the second page in the memory 72; when the webpage is opened again, the first page is obtained, after the webpage attribute in the first page is loaded, a page loading completion event is triggered, and a second page cached in the memory 72 is read; the memory 72 is used for caching the second page acquired by the browser 71.
Here, the first page may be referred to as a frame page, and includes a web page attribute and a page load completion event, where the web page attribute includes: CSS tags, JS tags and the like, wherein the page loading completion event is generally an onload event; the initialization request comprises a page initialization object request and a static resource request; the second page may be referred to as a content page, and includes web page content such as an HTML object, a CSS object, a JS object, and a picture of the web page.
The browser 71 is further configured to execute a delay time setting event after the page loading completion event is triggered, query whether there is a cached second page in the memory 72 within the delay time, and send an initialization request for the second page to the server after the delay time elapses when there is no cached second page.
In an embodiment, the browser 71 is specifically configured to receive a first page and a version number of a web page returned by a server, cache the version number and the corresponding second page in the memory 72 after obtaining the second page, when the web page is opened again, query whether there is a cached second page in the memory, compare whether the version number of the newly received web page is consistent with the version number cached in the memory 72 when there is the cached second page, read the cached second page when consistent, do not read the cached second page when inconsistent, send an initialization request for the second page to the server after the delay time expires, and then cache the new second page to cover the original second page in the memory.
In addition, the browser 71 needs to set the input in the cookie of the second page as false when acquiring the second page, and set the input as true after completely loading and caching the second page, so that the browser 71 may read the input first when reading the second page cached in the memory 72, if the input is true, the cached second page may be read, and if the input is false, the cached second page may not be read, and it is necessary to send an initialization request for the second page to the server after the delay time has elapsed, and acquire the second page through the initialization request.
The present invention also provides a server, as shown in fig. 8, including: a first page sending module 81 and a second page sending module 82; wherein the content of the first and second substances,
the first page sending module 81 may be implemented by a memory and a sending interface of the server, and sends a first page to the browser when receiving a first page request of the browser;
the first page sending module 82, which may also be implemented by a memory and a sending interface of the server, sends the second page to the browser after receiving an initialization request of the browser for the second page.
Based on the above terminal, the present invention also implements a browser caching system, as shown in fig. 9, the system includes: a terminal 91, a server 92; the terminal 91 is configured to, when a web page is opened for the first time, obtain a first page through the server 92, trigger a page loading completion event after loading a web page attribute in the first page, and execute an initialization request for a second page in the page loading completion event; acquiring a second page from the server 92 through the initialization request, and caching the second page to the local; when the webpage is opened again, the first page is obtained, after the webpage attribute in the first page is loaded, a page loading completion event is triggered, and a cached second page is read; the server 92 sends the first page to the terminal 91 when the terminal 91 opens the web page for the first time, and sends the second page to the terminal 92 after receiving an initialization request for the second page from the terminal 91.
As shown in fig. 5, the terminal 92 includes: a browser 71 and a memory 72; the browser 71 is configured to obtain a first page when a web page is opened for the first time, trigger a page loading completion event after loading a web page attribute in the first page, and execute an initialization request for a second page in the page loading completion event; acquiring a second page through the initialization request, and caching the second page in the memory 72; when the webpage is opened again, the first page is obtained, after the webpage attribute in the first page is loaded, a page loading completion event is triggered, and a second page cached in the memory 72 is read; the memory 72 is used for caching the second page acquired by the browser 71.
Here, the first page may be referred to as a frame page, and includes a web page attribute and a page load completion event, where the web page attribute includes: CSS tags, JS tags and the like, wherein the page loading completion event is generally an onload event; the second page may be referred to as a content page, and includes web page content such as an HTML object, a CSS object, a JS object, and a picture of the web page.
The browser 71 is further configured to execute a delay time setting event after the page loading completion event is triggered, query whether there is a cached second page in the memory 72 within the delay time, and send an initialization request for the second page to the server after the delay time elapses when there is no cached second page.
In an embodiment, the browser 71 is specifically configured to receive a first page and a version number of a web page returned by the server, cache the version number and the corresponding second page in the memory 72 after obtaining the second page, when the web page is opened again, query whether there is a cached second page in the memory, compare whether the version number of the newly received web page is consistent with the version number cached in the memory 72 when there is the cached second page, read the cached second page when consistent, do not read the cached second page when inconsistent, send an initialization request for the second page to the server after the delay time expires, and then cache the new second page to cover the original second page in the memory.
In addition, the browser 71 needs to set the input in the cookie of the second page as false when acquiring the second page, and set the input as true after completely loading and caching the second page, so that the browser 71 may read the input first when reading the second page cached in the memory 72, if the input is true, the cached second page may be read, and if the input is false, the cached second page may not be read, and it is necessary to send an initialization request for the second page to the server after the delay time has elapsed, and acquire the second page through the initialization request.
The browser caching method according to the embodiment of fig. 4 of the present invention may also be stored in a computer-readable storage medium if it is implemented in the form of a software functional module and sold or used as an independent product. Based on such an understanding, it will be apparent to one skilled in the art that embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media having computer-usable program code embodied therewith, including but not limited to, a U disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk storage device, a CD-ROM, an optical storage device, and the like.
The present application is described in terms of flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
Correspondingly, an embodiment of the present invention further provides a computer storage medium, in which a computer program is stored, where the computer program is used to execute the browser caching method according to the embodiment shown in fig. 4 in the present invention.
In summary, the page-separated caching method is used, original service codes in a webpage are not affected, most mainstream browsers can be supported, the implementation is simple, when F5 or Ctrl + F5 is clicked to refresh the webpage, HTTP resource requests do not need to be sent to a server, response messages returned by the server do not need to be received, requests and network traffic in the refreshing process can be effectively reduced, and the method has absolute advantages in high-concurrency and high-traffic scenes such as a shopping website.
The above description is only exemplary of the present invention and should not be taken as limiting the scope of the present invention, and any modifications, equivalents, improvements, etc. that are within the spirit and principle of the present invention should be included in the present invention.

Claims (16)

1. A browser caching method, characterized by comprising:
splitting a webpage into a first page and a second page in advance, and respectively configuring, wherein the first page comprises webpage attributes and a page loading completion event;
when a browser opens a webpage and does not find cache content of the webpage locally, determining to open the webpage for the first time, sending a first page request to a server to obtain the first page, triggering a page loading completion event after loading webpage attributes in the first page, and executing an initialization request for a second page in the page loading completion event; the first page is a frame page of a webpage, and the second page is a content page of the webpage;
acquiring a second page through the initialization request, loading and rendering the second page, and completely caching the second page to the local;
and when the webpage is opened again, acquiring the first page, triggering a page loading completion event after loading the webpage attribute in the first page, and reading the cached second page based on the version number of the webpage returned by the server.
2. The browser caching method according to claim 1, wherein the initialization request comprises a page initialization object request and a static resource request;
the second page includes a hypertext markup language (HTML) object, and/or a Cascading Style Sheet (CSS) object, and/or a js (javascript) object, and/or a picture of the web page.
3. The browser caching method of claim 1, wherein executing the initialization request for the second page in the page load complete event comprises: adding a set delay time (setTimeout) event into the page loading completion event, and executing the set delay time event after triggering the page loading completion event; and in the delay time, locally inquiring whether a cached second page exists, and when the cached second page does not exist, sending an initialization request for the second page to the server after the delay time is up.
4. The browser caching method of claim 3, wherein the obtaining the first page comprises: the browser receives the version numbers of the first page and the webpage returned by the server;
the caching the second page locally comprises: after the browser acquires a second page, caching the version number of the webpage and the second page to the local;
the reading of the cached second page based on the version number of the web page returned by the server comprises: and in the process of executing the delay time setting event, the browser locally inquires whether a cached second page exists, compares whether the version number of the webpage returned by the server is consistent with the version number in the cache when the cached second page exists, and reads the cached second page when the version number of the webpage returned by the server is consistent with the version number in the cache.
5. The browser caching method of claim 4, further comprising: and when the version number of the webpage returned by the server is inconsistent with the version number in the cache, the second page of the cache is not read, an initialization request for the second page is sent to the server after the delay time is up, and then the new second page of the cache covers the original second page of the local.
6. A browser caching method, characterized by comprising:
the method comprises the steps that a server sends a first page to a browser when receiving a first page request of the browser, and sends a second page to the browser after receiving an initialization request of the browser for the second page, so that the browser loads and renders the second page, and the second page is completely cached;
the method comprises the steps that when a browser opens a webpage and cache content of the webpage is not found locally, a server determines a first page sent when the webpage is opened for the first time, wherein the first page comprises webpage attributes and a page loading completion event; the first page is a frame page of a webpage, the second page is a content page of the webpage, and the frame page and the content page are separately configured.
7. The browser caching method according to claim 6, wherein the initialization request comprises a page initialization object request and a static resource request;
the second page comprises an HTML object, and/or a CSS object, and/or a JS object, and/or a picture of the web page.
8. A terminal, characterized in that the terminal comprises: a browser and a memory; wherein the content of the first and second substances,
the browser is used for splitting a webpage into a first page and a second page in advance and respectively configuring the first page and the second page, wherein the first page comprises webpage attributes and a page loading completion event; when a webpage is opened, when cache content of the webpage is not found locally, determining to open the webpage for the first time, sending a first page request to a server to obtain the first page, triggering a page loading completion event after loading webpage attributes in the first page, and executing an initialization request for a second page in the page loading completion event; the first page is a frame page of a webpage, and the second page is a content page of the webpage; acquiring a second page through the initialization request, loading and rendering the second page, and completely caching the second page to a memory; when the webpage is opened again, the first page is obtained, after the webpage attribute in the first page is loaded, a page loading completion event is triggered, and a second page cached in the memory is read based on the version number of the webpage returned by the server;
and the memory is used for caching the second page acquired by the browser.
9. The terminal according to claim 8, wherein the browser is further configured to execute a set latency event after triggering a page loading completion event; and inquiring whether a second page is cached in the memory within the delay time, and when the second page is not cached, sending an initialization request for the second page to the server after the delay time.
10. The terminal according to claim 9, wherein the browser is specifically configured to receive a first page and a version number of a web page returned by the server, cache the version number and the corresponding second page in the memory after acquiring the second page, when the web page is opened again, in the process of executing the delay time setting event, query whether there is a cached second page in the memory, compare whether a version number of a newly received web page is consistent with a version number of the cache of the memory when there is a cached second page, and read the cached second page when the version numbers are consistent.
11. The terminal of claim 10, wherein the browser is further configured to, when the version number of the newly received web page is not consistent with the version number of the memory cache, not read the cached second page, send an initialization request for the second page to the server after the delay time expires, and then cache the new second page to overwrite the original second page in the memory.
12. A server, characterized in that the server comprises: the device comprises a first page sending module and a second page sending module; wherein the content of the first and second substances,
the first page sending module is used for sending a first page to the browser when receiving a first page request of the browser;
the second page sending module is used for sending a second page to the browser after receiving an initialization request of the browser for the second page, so that the browser loads and renders the second page, and the second page is completely cached;
the first page sending module is used for determining a first page sent when the webpage is opened for the first time when the cache content of the webpage is not found locally when the webpage is opened by the browser, and the first page comprises webpage attributes and a page loading completion event; the first page is a frame page of a webpage, the second page is a content page of the webpage, and the frame page and the content page are separately configured.
13. A browser caching system, characterized in that it comprises a terminal according to any one of the preceding claims 8 to 11 and a server according to claim 12.
14. A terminal, comprising:
a memory for storing executable instructions;
a processor, configured to execute the executable instructions to implement the browser caching method according to any one of claims 1 to 5.
15. A server, comprising:
a memory for storing executable instructions;
a processor, configured to execute the executable instructions to implement the browser caching method according to claim 6 or 7.
16. A storage medium having stored thereon executable instructions for, when executed, implementing a browser caching method as claimed in any one of claims 1 to 5, or a browser caching method as claimed in claim 6 or 7.
CN201410201879.6A 2014-05-13 2014-05-13 Browser caching method and device Active CN105095280B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410201879.6A CN105095280B (en) 2014-05-13 2014-05-13 Browser caching method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410201879.6A CN105095280B (en) 2014-05-13 2014-05-13 Browser caching method and device

Publications (2)

Publication Number Publication Date
CN105095280A CN105095280A (en) 2015-11-25
CN105095280B true CN105095280B (en) 2020-02-14

Family

ID=54575733

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410201879.6A Active CN105095280B (en) 2014-05-13 2014-05-13 Browser caching method and device

Country Status (1)

Country Link
CN (1) CN105095280B (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105893425A (en) * 2015-12-04 2016-08-24 乐视致新电子科技(天津)有限公司 Page display method and apparatus
CN106874293B (en) * 2015-12-11 2020-12-29 北京国双科技有限公司 Data processing method and device
CN106202179B (en) * 2016-06-27 2020-02-11 北京奇虎科技有限公司 Page loading method and device
CN106874328B (en) * 2016-07-08 2021-03-19 创新先进技术有限公司 Data processing method and equipment
CN106354879A (en) * 2016-09-27 2017-01-25 北京奇虎科技有限公司 Webpage caching method and device
CN106709864B (en) * 2016-12-08 2019-03-12 彭志勇 Large capacity image buffer storage method based on WebGL
CN106682176A (en) * 2016-12-29 2017-05-17 北京五八信息技术有限公司 Page loading method, equipment and device
CN107463613A (en) * 2017-06-29 2017-12-12 北京五八信息技术有限公司 Page loading method and device
CN107368560A (en) * 2017-07-07 2017-11-21 腾讯科技(深圳)有限公司 Method for implementing page and device, the computer-readable recording medium of Mobile solution
CN107679108A (en) * 2017-09-14 2018-02-09 环球智达科技(北京)有限公司 A kind of method of persistence loading page
CN109948094B (en) * 2017-10-17 2021-07-23 中移(苏州)软件技术有限公司 WEB page loading method and device
CN108563469A (en) * 2017-10-20 2018-09-21 五八有限公司 page loading method, device, storage medium and terminal device
CN109213952A (en) * 2018-08-02 2019-01-15 平安科技(深圳)有限公司 Page access processing method, device, computer equipment and storage medium
CN110765386A (en) * 2019-10-28 2020-02-07 北京字节跳动网络技术有限公司 Webpage image monitoring method and device, electronic equipment and readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE10224102A1 (en) * 2002-05-31 2003-12-24 Abb Research Ltd Internet web page transmission system loads new main page in response to answer using script in hidden frame
CN1971559A (en) * 2005-11-26 2007-05-30 国际商业机器公司 Context based navigation assembly and method
CN101997927A (en) * 2010-11-18 2011-03-30 厦门市美亚柏科信息股份有限公司 Method and system for caching data of WEB platform
CN102436373A (en) * 2011-09-13 2012-05-02 上海普元信息技术股份有限公司 Method for realizing resource loading and resource hot-updating in distributed enterprise application system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102438045B (en) * 2011-12-07 2015-07-08 深圳市深信服电子科技有限公司 Method and system for pre-fetching web page, and method for accessing web page
CN102446222B (en) * 2011-12-22 2014-12-10 华为技术有限公司 Method, device and system of webpage content preloading

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
DE10224102A1 (en) * 2002-05-31 2003-12-24 Abb Research Ltd Internet web page transmission system loads new main page in response to answer using script in hidden frame
CN1971559A (en) * 2005-11-26 2007-05-30 国际商业机器公司 Context based navigation assembly and method
CN100580672C (en) * 2005-11-26 2010-01-13 国际商业机器公司 Context based navigation assembly and method
CN101997927A (en) * 2010-11-18 2011-03-30 厦门市美亚柏科信息股份有限公司 Method and system for caching data of WEB platform
CN102436373A (en) * 2011-09-13 2012-05-02 上海普元信息技术股份有限公司 Method for realizing resource loading and resource hot-updating in distributed enterprise application system

Also Published As

Publication number Publication date
CN105095280A (en) 2015-11-25

Similar Documents

Publication Publication Date Title
CN105095280B (en) Browser caching method and device
US8856263B2 (en) Systems and methods thereto for acceleration of web pages access using next page optimization, caching and pre-fetching techniques
US9641591B1 (en) Modifying web content at a client
US9509764B1 (en) Updating cached web content
US20170154013A9 (en) Ad blocking page display method and device
US9077681B2 (en) Page loading optimization using page-maintained cache
US8527862B2 (en) Methods for making ajax web applications bookmarkable and crawlable and devices thereof
US9450803B2 (en) Efficient delivery of content by virtualization of dynamic interaction with the document object model
CN106126693B (en) Method and device for sending related data of webpage
US9401949B1 (en) Client web content cache purge
US10291738B1 (en) Speculative prefetch of resources across page loads
CN104572777B (en) Webpage loading method and device based on UIWebView component
US8516041B1 (en) Pre-fetching asynchronously requested content
US11330075B2 (en) One-time cache
US10938879B2 (en) Third-party Ad acceleration
CN112637361B (en) Page proxy method, device, electronic equipment and storage medium
US9727643B2 (en) Managing loading of web pages
CN111367596A (en) Method and device for realizing service data processing and client
US9998559B2 (en) Preemptive caching of data
US10095791B2 (en) Information search method and apparatus
CN113742551A (en) Dynamic data capture method based on script and puppeteer
US10482507B2 (en) Handling digital advertisements in a communication network
US9225583B1 (en) Efficient delivery of content by virtualization of static interaction with the document object model

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant