Embodiment
The main thought of the application is, when user to access pages, for the content piecemeal of this page having buffer memory at local storage, the final updating time of described content piecemeal is on the page loaded by the final updating time and server contrasting the buffer memory of described each content piecemeal, determine whether the content needing to upgrade described content piecemeal, for the content piecemeal not needing to upgrade, do not need to initiate request to server, directly play up the cache contents of this content piecemeal to be presented on the relevant position of the page.For the content piecemeal needing to upgrade, by initiating Asynchronous Request to server, the content of described content piecemeal on the local updating page.
For making the object of the application, technical scheme and advantage clearly, below in conjunction with the application's specific embodiment and corresponding accompanying drawing, technical scheme is clearly and completely described.Obviously, described embodiment is only some embodiments of the present application, instead of whole embodiments.Based on the embodiment in the application, those of ordinary skill in the art are not making the every other embodiment obtained under creative work prerequisite, all belong to the scope of the application's protection.
According to the embodiment of the application, provide a kind of method of page access.
It is the flow chart of the method 100 of a kind of page access of the embodiment of the present application with reference to figure 1, Fig. 1.
As shown in Figure 1, in step S101, when user accesses a page, judge whether each content piecemeal of the described page exists buffer memory in local storage.
The described page can be the homepage of website, such as, and the homepage of news website, video website, music site etc.; Also can be the page of single content item, such as, the page etc. of a news in the page of commodity, news website in shopping website; Also can be the personal homepage on number of site, such as, microblogging homepage, forum's homepage individual in a forum, the account page etc. individual on shopping website of individual on microblogging website, and, the page of indication in the application, is not limited in above-mentioned several pages.
Specifically, when user is a first time access page, browser can send request to server, server returns the content of this page to browser according to this request, comprising the content of each content piecemeal of this page, the content of described content piecemeal can be the information of the one or more content items in described content piecemeal, such as, the title of the commodity on the page of commodity, the price of commodity, the vendor information of commodity, the information such as the sales volume of commodity, or the user name on the private page of user, the information such as personal information, or the behavioural habits information of user (such as, during user's on-line purchase commodity, the conventional means of payment etc.).Browser then can in local storage the content of the content piecemeal that caching server returns, when user again this page of request access time, if the content of this content piecemeal does not have expired, browser just can use the buffer memory of this content piecemeal in local storage.
Such as, when the page of user's first time access commodity, when receiving the content of each content piecemeal of this commodity page that server returns, browser can store the content of each content piecemeal in local storage, or, browser also can be configured to the content of a part of content piecemeal storing this page in local storage as required, as, the title of these commodity, vendor information etc., local storage can be such as buffer (cache), the local memory technology of browser can be utilized to carry out buffer memory to content piecemeal, browser local buffer technology includes but not limited to the UserData technology of Microsoft Internet Explorer, and the browser rs cache technology such as the local Storage of HTML5.The content of the content piecemeal be stored that is to say also can be called the content caching of content piecemeal by the buffer memory of content piecemeal, or is called the cache contents of content piecemeal.When user accesses the page of these commodity again, if it is expired to judge that the buffer memory of these content piecemeals does not have, then the cache contents of these content piecemeals directly can be used.
In step s 102, for the content piecemeal of the described page having buffer memory in local storage, contrast the final updating time that final updating time of the buffer memory of described content piecemeal and server are carried in the described content piecemeal of the described page, to determine whether the content needing to upgrade described content piecemeal.
When user once accesses this page, browser can also obtain the final updating time of described content piecemeal while each content piecemeal of the page described in buffer memory.Wherein, the final updating time can for final updating time of the content of described content piecemeal of recording in Last-Modified header, such as, server, while the content returning each content piecemeal to browser, can also send to browser the Last-Modified header recording the final updating time of described content.The described final updating time can also for being nested in this content piecemeal final updating time of recording in the hiding field in content piecemeal.Here, we can claim this time to be final updating time of the cache contents of described content piecemeal.The final updating time final updating time of the cache contents of this content piecemeal and server being carried in the described content piecemeal of the described page contrasts, namely, whether unanimously contrast these two times, if consistent, illustrate that the buffer memory of this content piecemeal in this locality is not expired, that is, the content upgrading described content piecemeal is not needed.
In step s 103, if determine that the content of described content piecemeal does not need to upgrade, then the buffer memory of described content piecemeal is played up, and be presented at the relevant position of the described page.
The final updating time consistency of the described content piecemeal of the described page is carried in when the final updating time of buffer memory and server that contrast described content piecemeal in step s 102, can determine that the content of described content piecemeal does not need to upgrade, then the buffer memory of described content piecemeal is played up, and be presented at the relevant position of the described page.Describedly to play up, i.e. the playing up of the page, browser can be filled on the relevant position of the page based on predetermined rule by not needing the content of the content piecemeal upgraded, such as, according to the statement being shown in color, background, font etc. in the page about described content Block Explicit write with CSS code or JS code, this content piecemeal is played up.
Such as, when the page of access commodity, when determining that the title content piecemeal of these commodity is not expired at the buffer memory of local storage, then can directly play up the buffer memory of the title content piecemeal of these commodity, namely, read the title of these commodity be buffered in local storage, this title is presented on the relevant position of this commodity page.
According to an embodiment of the application, for the content piecemeal not having buffer memory in local storage, the Asynchronous Request of this content piecemeal of access can be initiated to server, to obtain the content of this content piecemeal.Further, when after the content receiving the described content piecemeal that server returns according to described Asynchronous Request, can also in local storage the content of the described content piecemeal that buffer memory is returned by server.Can also play up to be presented to the content of the described content piecemeal that server returns according to described Asynchronous Request the relevant position of the described page.
According to an embodiment of the application, for the content piecemeal of the described page having buffer memory in local storage, if determine that the content of described content piecemeal needs to upgrade, then initiate the Asynchronous Request of the described content piecemeal of access to server, to upgrade the content of described content piecemeal.Further, when after the content receiving the described content piecemeal that server returns according to described Asynchronous Request, can also in local storage the content of the described content piecemeal that buffer memory is returned by server.Further, can also play up the content of the described content piecemeal that server returns according to described Asynchronous Request, and be presented at the relevant position of the described page.
According to the embodiment of the application, when the content of a content piecemeal upgrades due to the operation of user, upgrade the buffer memory of described content piecemeal in local storage, and upgrade the final updating time of described content piecemeal.
Fig. 2 is the flow chart conducted interviews respectively for each content piecemeal of the accessed page according to the embodiment of the present application.
In step s 201, for each content piecemeal of the described page, judge whether there is buffer memory in local storage, if there is not the buffer memory of described content piecemeal in local storage, then carry out step S202.
Such as, when user accesses the described page first time, each content piecemeal of the described page does not all have buffer memory in local storage.Or there are some content piecemeals to be not suitable for carrying out buffer memory, such as, the account balance data of user, owing to all can change when there is transaction at every turn, or the bean vermicelli incremental data of user's microblogging, may all can have new bean vermicelli to add after each this user's microblogging of access exits.Therefore such content is not suitable for carry out buffer memory.
In step S202, when there is not the buffer memory of described content piecemeal in local storage, initiate the Asynchronous Request of the described content piecemeal of access to server, to obtain the content of described content piecemeal.
Asynchronous Request is the request for local, the request that the content (the content piecemeal that content changes) namely changing (renewal) for local sends to server, do not need the full page that refresh requests accesses content, therefore, in the application, browser to the content piecemeal of this page not having buffer memory in local storage, can initiate the Asynchronous Request of this content piecemeal of access to server.Described Asynchronous Request can be asked for AJAX, and server makes response for this Asynchronous Request, that is, server receives this Asynchronous Request, returns the content of this content piecemeal according to the content of asking to browser.
Such as, when user accesses the page of certain commodity, judge the buffer memory of the price content piecemeal of not these commodity in local storage (namely, the not buffer memory of this commodity price data), browser then sends the Asynchronous Request of the price data obtaining these commodity to server, the price data of these commodity, according to this Asynchronous Request, is returned to browser by server.
In step S203, the content of the described content piecemeal that caching server returns according to described Asynchronous Request in described local storage.
According to an embodiment of the application, when after the content receiving the described content piecemeal that server returns the response of described Asynchronous Request, in this locality, the content of this content piecemeal can be carried out buffer memory, and the final updating time of this content piecemeal can be preserved, when again accessing this page with convenient user, the content that needs to upgrade this content piecemeal can be determined whether according to the described final updating time, or the need of the cache contents of this content piecemeal of renewal in this locality.
In step S204, the content of the described content piecemeal that server returns according to described Asynchronous Request is played up, and is presented at the relevant position of the described page.
After the content receiving this content piecemeal that server returns according to Asynchronous Request, the content of this content piecemeal can also be played up by browser.Particularly, when browser receives after server responds the content of the content piecemeal of asking that described Asynchronous Request returns, according to predetermined rule (such as, the display rule of this content piecemeal of JS language compilation, can by this rule buffer memory in local storage) relevant position being presented at the described page is played up to described content.
Such as, when user accesses the page of certain commodity, due to the buffer memory of the not price data content piecemeal of these commodity in local storage, browser sends the Asynchronous Request of the price data obtaining these commodity to server, server is according to this Asynchronous Request, the price data of these commodity is returned to browser, browser according to predetermined rule (such as, position, background etc. with this pricing information of JS language compilation shows in the page), the price data of these commodity is filled on the position of this commodity page display price.
It should be noted that, above-mentioned step S203 and S204 can perform simultaneously respectively, also can successively perform, and when successively performing, first perform which step, the application does not limit.
According to the embodiment of the application, when a content piecemeal in the described page of the judgement at step S201 place has buffer memory in local storage, then carry out step S205.
In step S205, contrast the final updating time that final updating time of the buffer memory of described content piecemeal and server load described content piecemeal on the page, to determine whether the content needing to upgrade described content piecemeal.When the result contrasted is the final updating time of the cache contents of this content piecemeal and server is carried in the final updating time consistency of this content piecemeal of this page, illustrate that the buffer memory of this content piecemeal in this locality is not expired, then determine the content not needing to upgrade this content piecemeal, and carry out step S206.
In step S206, when determining that the content of described content piecemeal does not need to upgrade, the content of the buffer memory of described content piecemeal being played up, and is presented at the relevant position of the described page.
Particularly, browser can by the buffer memory of this content piecemeal in local storage based on predetermined rule (such as, the rule such as position, background with this content piecemeal of CSS language, JS language compilation is played up) complete playing up of the page, that is, by the fills of this content piecemeal on the relevant position of the page.
Such as, when user accesses the page of commodity, contrast the final updating time of the buffer memory of price data in local storage of these commodity and the final updating time of the price data of these commodity, the result of contrast is time consistency, namely the price data upgrading these commodity is not needed, the cache contents of the price data of these commodity in local storage can be played up by browser, to be filled on the relevant position of this commodity page.
According to an embodiment of the application, when in step S205 place, contrast the final updating time that final updating time of the buffer memory of described content piecemeal and server are carried in this content piecemeal of the described page, when result is inconsistent, namely need the content upgrading this content piecemeal, then carry out step S202.
In step S202, when needing the content upgrading described content piecemeal, initiate the Asynchronous Request of the described content piecemeal of access to server, to upgrade the content of described content piecemeal.
Browser can to the content piecemeal not having buffer memory in local storage, the Asynchronous Request of this content piecemeal of access is initiated to server, server makes response for this Asynchronous Request, namely, server receives this Asynchronous Request, returns the content of this content piecemeal according to the content of asking to browser.
In step S203, the content of the described content piecemeal that buffer memory is returned according to described Asynchronous Request by server in described local storage.
According to an embodiment of the application, when after the content receiving this content piecemeal that server returns the response of this Asynchronous Request, in local storage, the content returning this content piecemeal can be carried out buffer memory, and the final updating time of this content piecemeal can be preserved, when again accessing this page with convenient user, can determine whether according to the final updating time of this content piecemeal the content that needs to upgrade this content piecemeal.
In step S204, the content of the described content piecemeal that server returns according to described Asynchronous Request is played up, and is presented on the relevant position of the described page.
Such as, when user accesses the page of commodity, contrast the buffer memory final updating time of price data in local storage and the final updating time of this commodity price data of these commodity, seller due to these commodity have changed the price of these commodity, in local storage buffer memory, the final updating time of this commodity price data that final updating time of the price data of these commodity and server are carried on the page of these commodity is inconsistent, therefore the Asynchronous Request of the price data of these commodity of access initiated by browser to server, server returns the price data of these commodity according to this Asynchronous Request.Browser receives the price data of the described commodity that server returns, and plays up according to pre-defined rule, and is presented on the relevant position of the described page.
According to an embodiment of the application, when the content of the content piecemeal of this page upgrades due to the operation of user, server can upgrade the final updating time of described content piecemeal.When user accesses again, browser contrasts final updating time of the buffer memory of this content piecemeal in local storage and server when being carried in the final updating Time Inconsistency of this content piecemeal of this page, can initiate the Asynchronous Request of the what be new obtaining this content piecemeal to server.
Specifically, when user access be certain application account time, may modify to the account information of oneself, such as, user logs in oneself payment accounts at Third-party payment platform, when entering the page of personal information, add the bank's card number used when paying on this page, or such as, user logs in oneself individual microblogging homepage, have changed personal information etc., when user determines amendment, server can upgrade the final updating time of this content piecemeal, when user accesses again, browser contrasts final updating time of the buffer memory of this content piecemeal in local storage and server when being carried in the final updating Time Inconsistency of this content piecemeal of this page, the Asynchronous Request of the what be new obtaining this content piecemeal can be initiated to server, and, the buffer memory of this content piecemeal of the content update that browser can also return according to server in this locality.
According to the embodiment of the application, step S201 ~ S204 is also applicable to the situation of user's first time request access page simultaneously.
In step s 201, because user accesses this page first time, therefore, in local storage, there is not the buffer memory of each content piecemeal of this page.
In step S202, for each content piecemeal, initiate the Asynchronous Request of the content of the described each content piecemeal of access to server, to obtain the content of each content piecemeal.
In step S203, the content of each content piecemeal returned according to each Asynchronous Request by server carries out buffer memory.
Meanwhile, in step S204, the content of each content piecemeal that returns according to each Asynchronous Request of rendering server respectively, and be presented at the relevant position of the described page respectively.
Present invention also provides a kind of page access device.
Fig. 3 schematically shows the structured flowchart of the device of a kind of page access according to the application's embodiment.According to an embodiment of the application, this device 300 can comprise: judge module 301, contrast module 302 and rendering module 303.
Wherein, judge module 301 may be used for when user accesses a page, judges whether each content piecemeal of the described page exists buffer memory in local storage.
Contrast module 302 may be used for contrast has the final updating time of the buffer memory of the content piecemeal of the described page of buffer memory and server to be carried in the final updating time of the described content piecemeal of the described page, to determine whether the content needing to upgrade described content piecemeal in local storage.
Rendering module 303 may be used for, when the content of the content piecemeal of the described page determining to have buffer memory in local storage does not need to upgrade, playing up to the buffer memory of described content piecemeal the relevant position being presented at the described page.
According to an embodiment of the application, device 300 can also comprise the first request module, this module may be used for the content piecemeal for the described page not having buffer memory in local storage, initiates the Asynchronous Request of the described content piecemeal of access, to obtain the content of described content piecemeal to server.
According to an embodiment of the application, device 300 can also comprise the second request module, this module may be used for when the content of the content piecemeal determining to have buffer memory in local storage needs to upgrade, the Asynchronous Request of the described content piecemeal of access is initiated, to upgrade the content of described content piecemeal to server.
According to an embodiment of the application, device 300 can also comprise cache module, and this module may be used for the content of the described content piecemeal that buffer memory is returned according to described Asynchronous Request by server in local storage.
According to an embodiment of the application, described rendering module can also be used for the relevant position playing up to be presented at the described page to the content of the described content piecemeal returned according to described Asynchronous Request by server.
According to an embodiment of the application, device 300 can also comprise preservation module, may be used for the final updating time of preserving described content piecemeal.
The function realized due to the device of the present embodiment is substantially corresponding to the embodiment of the method shown in earlier figures 1 to Fig. 2, therefore not detailed part in the description of the present embodiment, see the related description in previous embodiment, can not repeat at this.
By adopting the technical scheme of the application, when user accesses certain page first time, each content piecemeal of this page does not all have buffer memory in local storage, therefore send the Asynchronous Request of each content piecemeal of access to server, and the content of each content piecemeal returned according to server is carried out playing up with by the relevant position of the fills of each content piecemeal to the page respectively.When user accesses this page again, for the content piecemeal having buffer memory, if the buffer memory of this content piecemeal does not need to upgrade, then the direct buffer memory to this content piecemeal is played up to be filled into page relevant position, the repetitive requests to server can be reduced, thus double counting and the network overhead of server can be reduced, and, the loading velocity of the page can also be promoted.If buffer memory needs to upgrade, then send Asynchronous Request to upgrade the content of this content piecemeal, to realize the real-time update demand to data to server.
In one typically configuration, computing equipment comprises one or more processor (CPU), input/output interface, network interface and internal memory.
Internal memory may comprise the volatile memory in computer-readable medium, and the forms such as random access memory (RAM) and/or Nonvolatile memory, as read-only memory (ROM) or flash memory (flashRAM).Internal memory is the example of computer-readable medium.
Computer-readable medium comprises permanent and impermanency, removable and non-removable media can be stored to realize information by any method or technology.Information can be computer-readable instruction, data structure, the module of program or other data.The example of the storage medium of computer comprises, but be not limited to phase transition internal memory (PRAM), static RAM (SRAM), dynamic random access memory (DRAM), the random access memory (RAM) of other types, read-only memory (ROM), Electrically Erasable Read Only Memory (EEPROM), fast flash memory bank or other memory techniques, read-only optical disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tape, tape magnetic rigid disk stores or other magnetic storage apparatus or any other non-transmitting medium, can be used for storing the information can accessed by computing equipment.According to defining herein, computer-readable medium does not comprise non-temporary computer readable media (transitory media), as data-signal and the carrier wave of modulation.
Also it should be noted that, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thus make to comprise the process of a series of key element, method, commodity or equipment and not only comprise those key elements, but also comprise other key elements clearly do not listed, or also comprise by the intrinsic key element of this process, method, commodity or equipment.When not more restrictions, the key element limited by statement " comprising ... ", and be not precluded within process, method, commodity or the equipment comprising described key element and also there is other identical element.
Those skilled in the art should understand, the embodiment of the application can be provided as method, system or computer program.Therefore, the application can adopt the form of complete hardware embodiment, completely software implementation or the embodiment in conjunction with software and hardware aspect.And the application can adopt in one or more form wherein including the upper computer program implemented of computer-usable storage medium (including but not limited to magnetic disc store, CD-ROM, optical memory etc.) of computer usable program code.
The foregoing is only the embodiment of the application, be not limited to the application, for a person skilled in the art, the application can have various modifications and variations.Within all spirit in the application and principle, any amendment done, equivalent replacement, improvement etc., within the right that all should be included in the application.