Webpage refreshing method, webpage refreshing system and related device

文档序号:7878 发布日期:2021-09-17 浏览:40次 中文

1. A webpage refreshing method is characterized by comprising the following steps:

receiving a refreshing request of a webpage;

judging whether the browser sets a negotiation cache;

if yes, judging whether the refreshing request hits a view level cache or not; the view level cache is at least three levels;

and if the refreshing request contains the view level cache, returning the view level cache corresponding to the refreshing request so that the browser can refresh the webpage by using the view level cache.

2. The method for refreshing a web page according to claim 1, wherein before determining whether the browser sets the negotiation cache, the method further comprises:

judging whether the browser sets a forced cache or not;

if not, executing a step of judging whether the browser sets a negotiation cache;

if yes, judging whether the forced cache is overdue or not;

if the forced cache is overdue, executing a step of judging whether the browser sets a negotiation cache;

and if the forced cache is not expired, refreshing the webpage by utilizing the forced cache.

3. The web page refreshing method according to claim 1, wherein returning the view-level cache corresponding to the refresh request comprises:

analyzing request header data contained in the refreshing request to obtain a cache identifier corresponding to the view level;

and returning the view level cache corresponding to the cache identification.

4. The method for refreshing a web page according to claim 3, wherein if the request header data includes a browser-side view timestamp, returning to the view-level cache corresponding to the cache identifier comprises:

determining a latest view timestamp;

judging whether the browser-side view timestamp is consistent with the latest view timestamp;

and if the current view timestamp is inconsistent with the current view timestamp, taking the latest view timestamp and the corresponding level cache code as the view level cache corresponding to the request header data, storing the view level cache into response header data, and returning the response header data.

5. The method of claim 1, wherein if the refresh request does not include a view-level cache, further comprising:

and returning all the page source data so that the browser can render the page source data and refresh the webpage.

6. The web page refreshing method according to any one of claims 1 to 5, further comprising:

and determining a target element, adding a preset identifier to the target element, and generating the view level cache.

7. The web page refreshing method according to any one of claims 1 to 5, further comprising:

and configuring a corresponding unique identifier according to the directory structure of the webpage to generate the view level cache.

8. A web page refresh system, comprising:

the request receiving module is used for receiving a refreshing request of a webpage;

the first judgment module is used for judging whether the browser sets a negotiation cache;

the second judgment module is used for judging whether the refreshing request hits the view level cache or not when the judgment result of the first judgment module is yes; the view level cache is at least three levels;

and the webpage refreshing module is used for returning the view level cache corresponding to the refreshing request when the judgment result of the second judgment module is yes, so that the browser can refresh the webpage by using the view level cache.

9. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the web page refresh method according to any one of claims 1 to 7.

10. A server, characterized by comprising a memory in which a computer program is stored and a processor which, when calling the computer program in the memory, carries out the steps of the web page refresh method according to any one of claims 1 to 7.

Background

At present, most of pages pay attention to the loading speed of a first screen, most of applications have relatively complex first screens and frequent detail change, but part of pages cannot be changed, once all data of the pages are requested, most of data codes are repeated, and the code returned by a server is re-rendered to seriously influence the loading speed of the pages.

Disclosure of Invention

The application aims to provide a webpage refreshing method, a webpage refreshing system, a computer readable storage medium and a server, and the webpage loading speed is effectively improved by setting view level cache.

In order to solve the technical problem, the application provides a webpage refreshing method, which has the following specific technical scheme:

receiving a refreshing request of a webpage;

judging whether the browser sets a negotiation cache;

if yes, judging whether the refreshing request hits a view level cache or not; the view level cache is at least three levels;

and if the refreshing request contains the view level cache, returning the view level cache corresponding to the refreshing request so that the browser can refresh the webpage by using the view level cache.

Optionally, before determining whether the browser sets the negotiation cache, the method further includes:

judging whether the browser sets a forced cache or not;

if not, executing a step of judging whether the browser sets a negotiation cache;

if yes, judging whether the forced cache is overdue or not;

if the forced cache is overdue, executing a step of judging whether the browser sets a negotiation cache;

and if the forced cache is not expired, refreshing the webpage by utilizing the forced cache.

Optionally, returning the view level cache corresponding to the refresh request includes:

analyzing request header data contained in the refreshing request to obtain a cache identifier corresponding to the view level;

and returning the view level cache corresponding to the cache identification.

Optionally, if the request header data includes a browser-side view timestamp, returning to the view-level cache corresponding to the cache identifier includes:

determining a latest view timestamp;

judging whether the browser-side view timestamp is consistent with the latest view timestamp;

and if the current view timestamp is inconsistent with the current view timestamp, taking the latest view timestamp and the corresponding level cache code as the view level cache corresponding to the request header data, storing the view level cache into response header data, and returning the response header data.

Optionally, if the refresh request does not include a view level cache, the method further includes:

and returning all the page source data so that the browser can render the page source data and refresh the webpage.

Optionally, the method further includes:

and determining a target element, adding a preset identifier to the target element, and generating the view level cache.

Optionally, the method further includes:

and configuring a corresponding unique identifier according to the directory structure of the webpage to generate the view level cache.

The present application further provides a web page refreshing system, including:

the request receiving module is used for receiving a refreshing request of a webpage;

the first judgment module is used for judging whether the browser sets a negotiation cache;

the second judgment module is used for judging whether the refreshing request hits the view level cache or not when the judgment result of the first judgment module is yes; the view level cache is at least three levels;

and the webpage refreshing module is used for returning the view level cache corresponding to the refreshing request when the judgment result of the second judgment module is yes, so that the browser can refresh the webpage by using the view level cache.

The present application also provides a computer-readable storage medium having stored thereon a computer program which, when being executed by a processor, carries out the steps of the method as set forth above.

The present application further provides a server comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method described above when calling the computer program in the memory.

The application provides a webpage refreshing method, which comprises the following steps: receiving a refreshing request of a webpage; judging whether the browser sets a negotiation cache; if yes, judging whether the refreshing request hits a view level cache or not; the view level cache is at least three levels; and if the refreshing request contains the view level cache, returning the view level cache corresponding to the refreshing request so that the browser can refresh the webpage by using the view level cache.

According to the method and the device, when the webpage refreshing is executed, whether the browser sets the negotiation cache or not is judged firstly, when the browser sets the negotiation cache, the server side can return the view level cache corresponding to the refreshing request without returning all data of the webpage, transmission of repeated level flow is saved, the browser cache is fully utilized, the page can be generated quickly, the webpage loading time is shortened, and the comfort of user webpage browsing is enhanced.

The application also provides a webpage refreshing system, a computer readable storage medium and a server, which have the beneficial effects and are not described herein again.

Drawings

In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced below, it is obvious that the drawings in the following description are only embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.

Fig. 1 is a flowchart of a web page refreshing method according to an embodiment of the present application;

fig. 2 is a schematic structural diagram of a web page refreshing system according to an embodiment of the present application.

Detailed Description

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

Referring to fig. 1, fig. 1 is a flowchart of a web page refreshing method according to an embodiment of the present application, where the method includes:

s101: receiving a refreshing request of a webpage;

the step is intended to receive a refresh request of a web page, where the refresh request may be an active request or a passive refresh request generated according to preset refresh parameters. For example, a user may be actively generating a refresh request when opening a web page at a home page. The web page in this step may be originated from various terminal devices capable of running web pages, and it should be noted that the web page may be a mobile terminal web page, for example, an application interface on a mobile terminal, which may be used as the web page in this embodiment.

The specific content of the refresh request is not limited herein, and at least the cache request should be included, but the specific content of the cache request is not specifically limited.

S102: judging whether the browser sets a negotiation cache; if yes, entering S103;

this step is intended to determine whether the browser has set up a negotiation cache. The negotiation cache is used for negotiation interaction between the client side containing the browser and the server side so as to judge whether the cache resources are overdue. When the resource is requested, the identifier of the local cache of the browser is brought to the server side at the same time, and the server side compares the latest resource. If the cache resources are not changed, the browser reads the local cache. And if the cache resources are changed, returning the latest resources.

S103: judging whether the refreshing request hits a view level cache or not; if yes, entering S104;

when the browser sets the negotiation cache, the comparison process of the local resource and the latest resource is not directly executed at the server, but whether the refresh request contains the view level cache is judged. In this embodiment, if the refresh request includes a view level cache, it is default that view layering is performed on the web pages in the browser before the execution of this embodiment. There is no limitation on how the web page view layering is performed. The present embodiment provides several web page view layering methods:

the first method comprises the following steps: and determining a target element, adding a preset identifier to the target element, and generating the view level cache.

Namely, a user can customize a target element as a layer of view, and add a corresponding preset identifier to obtain a view level cache of the target element, which is equivalent to separate classification of the target element from local webpage resources, and corresponding view layering is performed in a server. For example, a certain div may be given a corresponding view level, with the attribute denoted by s-index.

And the second method comprises the following steps: and configuring a corresponding unique identifier according to the directory structure of the webpage to generate the view level cache.

The view layering can also be performed according to the directory structure of the web page, for example, the html element of the root node is a first layer, the body and body same level is a second layer, the next layer of the body is a third layer, and so on. Of course, each level contains a corresponding unique identification.

And the third is that: and carrying out first-class view layering according to the directory structure of the webpage, and configuring a custom hierarchy item on the basis of the first-class view layering.

That is, the first view layering method and the second view layering method are combined, and preferably, the first mode and the second mode can be combined and divided into two modes in the practical application process of view layering. The first is the default mode, where each level is automatically tagged with a unique v-index, with reference to the level of the directory tree for the web page element. The second mode can manually set a v-index for the element, the element with the v-index can cache the corresponding unique identifier, two hierarchical modes can coexist, in order to make view layering convenient, a default mode can be set to be started by default, and the manual mode can be set freely.

Regardless of the view layering approach, there should be at least less than three layers, but not too many, and generally no more than 10 layers. Each view level should have a unique corresponding identifier, and the adopted view level should be generated in a manner of being configured with a server side protocol, so that the server side can return to the corresponding view level cache when receiving a refresh request hitting the view level cache.

In addition, the determination of whether the refresh request hits in the view level cache in this step refers to determining whether the refresh request includes a request for the view level cache, or other types of requests having the same effect as the view level cache request, such as a request including a unique identifier of a corresponding view level.

S104: and returning the view level cache corresponding to the refreshing request so that the browser can refresh the webpage by using the view level cache.

When a view-level cache is hit in the refresh request, the corresponding view-level cache is returned. Specifically, request header data included in the refresh request may be analyzed to obtain a cache identifier corresponding to the view level, that is, the view level cache corresponding to the cache identifier may be returned.

It should be noted that how to return the view-level cache corresponding to the refresh request is not limited, and it should respond to different refresh requests.

For example, if the request header data includes a browser-side view timestamp, the following steps may be included when executing the view-level cache corresponding to the cache identifier:

firstly, determining a latest view timestamp;

secondly, judging whether the browser end view timestamp is consistent with the latest view timestamp; if not, entering a third step;

and thirdly, taking the latest view timestamp and the corresponding level cache code as the view level cache corresponding to the request header data, storing the view level cache into response header data, and returning the response header data.

The server determines the latest view timestamp of the server and judges whether the browser view timestamp in the request header data is consistent with the latest view timestamp of the server, and since the latest view timestamp in the server is the current latest version, once the latest view timestamp in the server is inconsistent with the current latest version, the latest view timestamp in the server lags behind the latest view timestamp in the server. It should be noted that, both the browser-side view timestamp and the service-side view timestamp refer to the latest version time of the corresponding cache, that is, the browser-side view timestamp refers to the last update time of the current version cached in the browser, and the service-side latest view timestamp refers to the last update time of the current version cached by the service-side.

And when the two are not consistent, the server stores the latest view timestamp and the corresponding hierarchy cache code into the response header data and returns the response header data. It is easy to understand that, after receiving the response header data, the browser refreshes the page by using the hierarchical cache code corresponding to the latest view timestamp, and may also update its own browser-side view timestamp to the latest view timestamp.

In the above process, both the view timestamp of the browser end and the view timestamp of the server end play a role of a cache identifier, that is, a cache identifier corresponding to the view level cache, and of course, a person skilled in the art may also adopt other forms of cache identifiers on the basis of this embodiment to implement a comparison process when the view level cache between the browser end and the server end is updated, which is not limited herein by way of example, and which should also be within the scope of the present application.

In addition, in this embodiment, if the refresh request does not include the view level cache, all the page source data may be returned at this time, so that the browser renders the page source data and refreshes the web page.

It should be noted that the server in this embodiment includes a server and other server devices that can receive a refresh request from the browser and respond to the refresh request.

According to the embodiment of the application, when the webpage refreshing is executed, whether the browser is set with the negotiation cache is judged firstly, when the browser is set with the negotiation cache, the server side can return the view level cache corresponding to the refreshing request without returning all data of the webpage, the targeted refreshing during the webpage refreshing is realized, the transmission of repeated level flow is saved, the browser cache is fully utilized, the webpage can be generated quickly, the webpage loading time is shortened, and the comfort of user webpage browsing is enhanced.

Based on the foregoing embodiment, as a preferred embodiment, before determining whether the browser sets the negotiation cache, the method may further include the following steps:

s201: judging whether the browser sets a forced cache or not; if not, entering S202; if yes, entering S203;

s202: executing the step of judging whether the browser sets the negotiation cache;

s203: judging whether the forced cache is expired; if not, entering S204; if yes, returning to S202;

s204: and refreshing the webpage by utilizing the forced cache.

The present embodiment aims to perform the judgment of forced caching before performing the negotiation caching. Before initiating a request resource, the browser may first determine whether to hit the forced cache according to the request header fields Expires and the cache-control, and if so, directly read the local cache resource, no longer send a request to the server, and return a corresponding status code, for example, the status code may be 200. When a browser requests a certain file, the server performs cache configuration on the file in response header data. The caching time and the caching type are controlled by the server, and the method specifically comprises the following steps: a common setting for cache-control in response to header data is max-image public private no-cache no-store, etc. In short, the forced cache sets an expiration time, and the client will see whether the resource is expired every time the client requests the resource, and will send the request to the server again only after the client expires.

If the forced cache is not hit, the browser initiates a request with some request header fields, and the server judges whether the negotiated cache is hit or not according to the fields. E.g., if-none-match and if-modified-nonce, which are request header fields that the browser sends to the server. The if-none-match value contains the Etag value in the response header field of the resource returned by the last request server, the Etag value is the unique identifier generated by the server according to the resource file, and the Etag value is unchanged as long as the resource file is unchanged.

And if-modified-sequence is to a last-modified value for indicating last time of return of the service end, the last-modified includes a date of last modification of the response resource at the service end, and the if-modified-sequence recorded by the browser end corresponds to the browser end view timestamp in the above embodiment. Then the server side judges if the if-none-match of the request field and the Etag value produced according to the resource file requested by the server side are the same or not, and judges if the unique identification is the same or not. Or judging if-modified-sequence of the request field and the last modification time of the resource of the server side, namely the latest view time stamp in the server side to compare. If the same indicates that the resource is not changed, the resource file is not returned, which indicates that the negotiation cache is available, and at this time, the code corresponding to the negotiation cache may be returned, for example, return 304, which is used to notify the browser end to directly read the local cache resource. If the difference indicates that the server resource is changed, the requested resource file is returned, and a corresponding status code, for example 200, can also be returned.

When step S202 of the present embodiment is executed, reference may be made to the processes of S102 to S104 in the above-described embodiments, and a description thereof will not be repeated.

The following describes a specific parameter setting process for view level cache and corresponding configuration of a service end:

the view level can adopt a key value pair in a specific storage mode of a request header, specifically, a key word uses v-index, a value uses an object for storage, and the stored content is a timestamp or a unique identifier of the current view update. If the corresponding html code segment is updated, difference comparison is carried out when the html code segment is issued, the corresponding v-index timestamp is updated, when the browser sends a refresh request, the hierarchy identifier returned by the server side before is carried, the server side compares the latest hierarchy identifier with the identifier in the browser refresh request, if the latest hierarchy identifier is consistent with the identifier in the browser refresh request, the html code segment is not returned, if the latest hierarchy identifier is inconsistent with the identifier in the browser refresh request, the updated html code segment corresponding to the v-index is returned, the browser receives the corresponding code segment, refreshing of the webpage is carried out, and due to the fact that only part of html codes need to be re-rendered during refreshing, the webpage refreshing speed can be improved.

The server may set a response header to configure whether to use a view level mode, for example, a field is view-store, and a corresponding value is, none, which indicates that a view level is not used; auto, auto mode with level 3 and level mode. When the level is set, a level can be set for a specific html internal tag, and the specific setting is as follows, for example, an html v-index is equal to "4" > level cache tag </html >, after the setting is performed in this way, the server can judge that there are several levels of the v-index set on the tag html, and then set a v-index-data of a specific cache identifier for each level in the several levels, and when the browser requests again, the cache identifiers are compared, and nodes of different cache identifiers are returned. The embodiment also plays a role in js and css codes, and can effectively reduce the transmission of redundant codes so as to achieve the purpose of quick code transmission and be beneficial to quick page refreshing.

The view level storage manner and the configuration parameters of the server side provided in this embodiment are a more specific implementation process disclosed in this application, and those skilled in the art may adopt other setting manners based on this embodiment and shall also fall within the protection scope of this application.

In the following, the web page refreshing system provided by the embodiment of the present application is introduced, and the web page refreshing system described below and the web page refreshing method described above may be referred to correspondingly.

Fig. 2 is a schematic structural diagram of a web page refreshing system provided in an embodiment of the present application, and the present application further provides a web page refreshing system, including:

a request receiving module 100, configured to receive a refresh request of a web page;

a first judging module 200, configured to judge whether the browser sets a negotiation cache;

a second determining module 300, configured to determine whether the refresh request hits in the view level cache if the first determining module 200 determines that the refresh request hits in the view level cache; the view level cache is at least three levels;

the web page refreshing module 400 is configured to, if the determination result of the second determining module 300 is yes, return to the view level cache corresponding to the refresh request, so that the browser refreshes the web page by using the view level cache.

Based on the above embodiment, as a preferred embodiment, the method further includes:

the system comprises a forced cache judging module, a negotiation cache judging module and a negotiation cache judging module, wherein the forced cache judging module is used for judging whether the browser sets the forced cache or not before judging whether the browser sets the negotiation cache or not; if not, entering a first judgment module 200; if yes, judging whether the forced cache is overdue or not; if the forced cache is expired, entering a first judgment module 200; and if the forced cache is not expired, refreshing the webpage by utilizing the forced cache.

Based on the above embodiment, as a preferred embodiment, the web page refreshing module 400 includes:

the analysis unit is used for analyzing the request header data contained in the refreshing request to obtain a cache identifier corresponding to the view level;

and the return unit is used for returning the view level cache corresponding to the cache identification.

Based on the foregoing embodiment, as a preferred embodiment, if the request header data includes a browser-side view timestamp, the webpage refreshing module 400 includes:

a response data returning unit for determining a latest view timestamp; judging whether the browser-side view timestamp is consistent with the latest view timestamp; and if the current view timestamp is inconsistent with the current view timestamp, taking the latest view timestamp and the corresponding level cache code as the view level cache corresponding to the request header data, storing the view level cache into response header data, and returning the response header data.

Based on the above embodiment, as a preferred embodiment, the method further includes:

and the refreshing module is used for returning all the page source data if the refreshing request does not contain the view level cache so that the browser can render the page source data and refresh the webpage.

Based on the above embodiment, as a preferred embodiment, the method further includes:

the first view level generation module is used for determining a target element, adding a preset identifier to the target element and generating the view level cache.

Based on the above embodiment, as a preferred embodiment, the method further includes:

and the second view level generation module is used for configuring a corresponding unique identifier according to the directory structure of the webpage and generating the view level cache.

The present application also provides a computer readable storage medium having stored thereon a computer program which, when executed, may implement the steps provided by the above-described embodiments. The storage medium may include: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.

The application also provides a server, which may include a memory and a processor, where the memory stores a computer program, and the processor may implement the steps provided by the foregoing embodiments when calling the computer program in the memory. Of course, the server may also include various network interfaces, power supplies, and the like.

The embodiments are described in a progressive manner in the specification, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. For the system provided by the embodiment, the description is relatively simple because the system corresponds to the method provided by the embodiment, and the relevant points can be referred to the method part for description.

The principles and embodiments of the present application are explained herein using specific examples, which are provided only to help understand the method and the core idea of the present application. It should be noted that, for those skilled in the art, it is possible to make several improvements and modifications to the present application without departing from the principle of the present application, and such improvements and modifications also fall within the scope of the claims of the present application.

It is further noted that, in the present specification, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:一种可配置化的web表单实现方法

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!