Summary of the invention
The method that the invention discloses a kind of WEB platform data caching, including:
Client modules is from the main body frame of server module webpage, the data cell content without caching, net
The each data cell attribute information of page;Described data cell attribute mainly includes whether data cell is available for client
The information such as module caching, Update Level, version;
Client modules analyzes in described webpage whether have need according to described webpage each data cell attribute information
Data cell to be cached;
If webpage existing and needs buffered data units, it is judged that whether client modules this locality existing described need
Data cell to be cached;
If there is not the data cell of needs caching in client modules this locality, from server module acquisition request
The described data cell needing caching, carries out locally stored, and generates the version information of described data cell;
If there is the data cell of described needs caching in this locality, it is judged that the genus of the data cell of these needs caching
Update Level in property information;
According to described Update Level, the described data cell needing caching is obtained.
Preferably, in the Update Level in the attribute information of the data cell of these needs of described judgement caching, institute
State Update Level to include never updating, needing once in a while to update, it is frequently necessary to update;Described according to described renewal
The described data cell needing caching is obtained by rank: if the described data needing caching
The Update Level of unit is for never to update, and when accessing webpage, client modules reads this data from this locality every time
Unit loads;If the Update Level of this data cell is for needing once in a while to update, when time client mould
When block accesses target web in the start cycle first, obtain the version letter of this data cell from server module
Breath, contrasts with the version information of this version information with this locally stored data cell, if version letter
Breath difference, then ask this data cell content from service end, and replace locally stored data cell;As
Really the Update Level of this data cell is for it is frequently necessary to update, and asks to access this webpage at client modules every time
Time, all the version information obtained from service end will be compared with locally stored version information, if version
This information is different, then ask this data cell content from service end, and replace locally stored data cell.
Preferably, also include: client modules loading data unit is to the webpage from service end acquisition request
In main body frame, and with without the data cell content complete web page display of composition of caching.
Preferably, described client modules analyzes described webpage according to described webpage each data cell attribute information
In whether there is a need to caching data cell be further: client modules is according to webpage each data cell attribute
Information analyzes all data cell attributes in webpage one by one, it is judged that whether there is a need to the data sheet of caching in webpage
Unit.
Preferably, also include: according to WEB portal service provider issue or update web resource time
Instruction, arranges data cell attribute.
Preferably, client modules is from the main body frame of server module webpage, without the data cell cached
In content, webpage each data cell attribute information, client uses the Ajax page without refreshing when sending request
Mechanism.
Preferably, if version information is different, then asks this data cell content from service end, and replace this
After the data cell that ground has stored, the version of more new data element.
The invention also discloses the system of a kind of WEB platform data caching, be made up of two parts: service end
Module and client modules;
Described server module includes that network service submodule, back-end data sub module stored, page resource set
Put submodule, page data output sub-module;
Described network service submodule, for providing network service for client modules;
Described back-end data sub module stored, is connected with described network service submodule, for storage from service
The data cell of the needs caching that end module obtains and data cell correlation attribute information;
Described page resource arranges submodule, is connected with back-end data storing sub-units, for in webpage
Data cell attribute be configured, and guide data cell and client for arranging control according to described attribute
End module between mutual;The attribute of described data cell include id, whether cache switch, Update Level,
Version information;
Page data output sub-module, arranges submodule with described page resource and is connected, for according to client
The connection request of module and page resource arrange submodule to the data cell attribute facilities in webpage,
Generate the main frame of the page and need not the data resource of client-cache, and being returned it to by network
Client modules;
Client modules includes that data load submodule, Data Control submodule, data sub module stored, number
According to showing four submodules such as submodule;
Described data load submodule, are connected with Data Control submodule, for obtaining the net that service end returns
The main body frame of page, the data cell content without caching, the data cell of needs caching, each data of webpage
Cell attribute information etc., and transferred to Data Control submodule;
Data sub module stored, for needing the data cell of caching to carry out this locality to the webpage of WEB system
Change storage, and store the version information of data cell;
Data Control submodule, for opening up different memory spaces for different websites, for Data Control
Module carries out storage and the reading of data cell;
Data Control submodule, loads submodule, data sub module stored, data display submodule with data
It is connected, is mainly used in loading submodule according to data and obtains webpage each data cell attribute information, analyze webpage
In whether there is a need to caching data cell;And be used for judging whether this locality exists the data cached list of described needs
Unit and the Update Level needing buffered data units;And control data loading submodule according to analyzing judged result
Loading to web data, controls the storage that data sub module stored is data cached to needs, controls data exhibition
Show the submodule displaying to web data;
Data display subelement, and data fast with Data Control submodule load submodule and are connected, are used for loading
Data cell is in the main body frame from the webpage of service end acquisition request, and with without the data cell of caching
The web page display that content composition is complete.
Present invention achieves the configurable cache of the site resource that a part is seldom updated, decrease web and visit
Ask, saved access resource and improve access ageing.
Detailed description of the invention
One embodiment of the present of invention discloses the method for a kind of WEB platform data caching, as shown in Figure 1.
Mainly comprise the steps:
Step 1, according to WEB portal service provider issue or update web resource time instruction, if
Put data cell attribute.
Here, data cell attribute mainly includes that the client modules that whether is available for of data cell caches, updates
The information such as rank, version.When data cell is updated, its version information is updated.
In this step, web resource is the various data cells in webpage, including monomer resource, such as: picture,
Flash document, js document, css document, xml document etc.;Also include mixing resource, such as: table (form,
Html tag, provides the element of structure with normalized row and column for the data content in html document),
(layer, html tag, be used for the content for bulk in html document (block-level) provides knot to div
Structure and the element of background) etc., mixing resource typically at least includes two or more monomer resources.
It addition, the various data resources in service end webpage are present in the main body frame of webpage, service end net
The main body frame of page is attached on trunk as leaves such as trunk, each data cell of webpage.
Each data cell all comprises two parts information: attribute and content.The attribute of data cell include id,
Whether caching switch, Update Level, version informations etc., attribute is arranged submodule by service end page resource and enters
Row is arranged, and is read out and analyzes in client controls submodule.The content of data cell is by its attribute certainly
Whether determine to carry out caching and how updating in client, the content of data cell will be embodied directly in user's
In browser interface.
In the most large-scale WEB website, all of site resource presses its renewal frequency, substantially can draw
It is divided into following several Update Level: never update, update once in a while, often update, update constantly.The most constantly
The information updated, the necessity of its caching is the least, and the resource updating class constantly typically need not caching, such as:
News, stock information, forum postings etc. in real time, it is desirable to client transmission access request the most directly connects every time
Connect service end and obtain web page resources;And other a few class WEB portal service providers can be according to practical situation
Each data cell of webpage is configured, is optimized the access speed of webpage by the caching of client.
The version information of data cell can be defined as a special character string, and this character string is by blockette
Becoming, it is also possible to comprise some letters, concrete form is defined by WEB portal service provider oneself, such as:
V.2010.0012, the version that this data cell is the 12nd issue issued for 2010 is represented.It is, in general, that
Numerical value this version of the biggest expression is the newest.
Step 2: client modules is from the main body frame of server module webpage, without the data cell cached
Content, webpage each data cell attribute information.
In this step, client modules request accesses the web data of server module, and receives loading service
The main body frame of webpage, the data cell content without caching, each number of webpage is generated after end module response request
According to cell attribute information.
Step 3: whether client modules is analyzed in webpage according to webpage each data cell attribute information and be there is a need to
The data cell of caching.
In this step, client background controls submodule and analyzes one by one according to webpage each data cell attribute information
All of data cell attribute in this webpage, including judging whether to there is a need in webpage the data cell of caching.
Step 4: need buffered data units if existed in webpage, then judge whether this locality exists described need
Want buffered data units.
Step 5: if client modules this locality does not exist the data cell of needs caching, from server module
The data cell of these needs of acquisition request caching, and carry out locally stored, and generate the version of this data cell
Information.
In this step, if this locality does not exist the data cell of needs caching, client data controls submodule
Request will be sent by loading submodule, and obtain this data cell with Connection Service end, and store client
In sub module stored, generate the version information of this data cell simultaneously.
Step 6: there is, if local, the data cell needing caching, then determine whether what these needs cached
Update Level in the attribute of data cell.
According to Update Level, point three kinds of situations, performed by following 7,8,9 steps.
Step 7: if the Update Level of the data cell of these needs caching is for never to update, every time access net
During page, client modules reads this data cell and loads from this locality.
In this step, when accessing this page every time, all it is not connected to server and obtains this resource, and only read visitor
The data of family end local datastore submodule.
In this step, the Banner (banner of webpage or headline) of such as webpage, Js document,
Css document etc., this type of resource typically will not update after website service is carried out again.In this case, one
This resource of denier is the most saved in client data sub module stored, then can not connect when user to access pages
Connect service end and obtain this resource, and only read the locally stored data of client and can achieve the goal.
Step 8: if the Update Level of this data cell is for needing once in a while to update, when time client modules
When the start cycle accesses target web first, obtain the version information of this data cell from server module,
Contrast with the version information of this version information with this locally stored data cell, if version information is not
With, then ask this data cell content from service end, and replace locally stored data cell.
The concrete operations of this step are: then client data controls submodule by utilization loading submodule transmission even
Connecing request, by the id of this data cell of network delivery to service end, and service end generates according to id parameter
The content of this data cell, and it is back to client.Client loads submodule and obtains what service end returned
Data cell content, controls submodule by client, deletes the old version of this data cell, and preserve
The data cell content of redaction is in client sub module stored, in order to other time read.
In this step, the advertising message more such as thrown in this WEB website, some bulletin category information etc.
Deng, this type of resource updates frequency ratio is relatively low, but needs for renewal every a period of time.In this case,
When accessing this webpage in this start cycle first, ability comparison web data unit is locally stored with client
The resource version information of submodule, and other time open this website and do not compare and directly transfer this locality
The resource of storage.The start cycle refers to that client PC is when this section of unlatching machine to closing machine
Between.
Step 9: if the Update Level of this data cell is for it is frequently necessary to update, then at client modules
When request accesses this webpage every time, all the version information obtained from service end will be believed with locally stored version
Breath is compared, if version information is different, then asks this data cell content from service end, and replaces this
The data cell that ground has stored.
The most do not ask the information of real-time update, video information etc..In this case, it is desirable to visit every time
Ask the data cell of this webpage all comparison webpages and the resource version information of the locally stored submodule of client.
Step 10: the main body frame of client modules loading data unit to the webpage from service end acquisition request
In, and and without the data cell content complete webpage of composition of caching, show together.
In this step, when the version of data cell and the locally stored submodule of client modules of server module
When the data cell version of middle taking-up is consistent, then client control submodule by the id according to this data cell and
Version information directly reads the content of the data cell that locally stored submodule is stored and loads.
When service end resource version is new than the data cell of the locally stored submodule of client, then visitor
Family end loads the data cell newly obtained from service end.
It is also preferred that the left the main body frame of browser-presented webpage and the data sheet that need not cache in the present embodiment
Unit, and in those data cells that must cache, some may need backstage Connection Service end to load,
This operation may need the some time, and therefore these web data unit can show such as and " loading number
According to, please wait ... " etc. make man-machine interaction more friendly.
During it is also preferred that the left client data control submodule will send request by loading submodule in the present embodiment
The Ajax page can be used to carry out interacting with server module without the technology of flush mechanism, the most both may be used
To alleviate the burden to network and server, the efficiency that raising processes, simultaneously access page without interrupting user
The interaction flow of face data.
It is also preferred that the left in the present embodiment, carry out the request of data cell when client loads submodule by data
Time, the page will create an XmlHttpRequest object, sends parameter to server, and right by this
As producing an XmlDoc object receiving the data that service end passes over, client data loads submodule
Block resolves XmlDoc object by Dom and will be further processed.
It is also preferred that the left can be by the content of text of this data cell during service end generation data cell in the present embodiment
Carry out encoding (may be used without the coded formats such as UTF-8) by UniCode form, in order to client is resolving
During produce exception because of some special character.
By the description of the present embodiment, the present invention program, it is to avoid traditional browser rs cache technology for
The web page resources of type all loads or the defect of the clean cut being all not loaded with, by not
The data resource often updated caches, it is achieved the WEB portal service provider of service end can be autonomous
Its web page resources of control whether cache in client, to reach to reduce between service end and client
Alternately, the purpose of the interface access speed of user is improved.
As in figure 2 it is shown, second embodiment of the invention provides the system of a kind of Web platform data caching.
System is mainly made up of two parts: server module and client modules.
Wherein, server module includes network service submodule, back-end data sub module stored, page resource
Four submodules such as submodule, page data output sub-module are set.
Network service submodule, for that run in a network environment, service-oriented, based on distributed program
Software module, use the Internet universal standard such as HTTP and XML so that people can be different
Local by the data on different terminal unit access WEB, for providing network clothes for client modules
Business.
Back-end data sub module stored, is connected with network service submodule, for organizing according to data structure,
Storage and the warehouse of management data.Can be that network data stores data base, such as sqlserver, mysql number
According to storehouse etc..The data cell needing caching obtained from server module for storage and data cell are correlated with and are belonged to
Property information.
Page resource arranges submodule, is connected with back-end data storing sub-units, for WEB website service
Provider is configured for the data cell attribute in webpage when issuing web resource, the genus of data cell
Property includes id, whether caches switch, Update Level, version information etc..And be used for controlling to guide this data sheet
Unit and client modules between mutual.
Data cell in webpage can be the monomer resource of webpage, such as: picture, flash document, js document,
Css document, xml document etc.;Can also be for mixing resource, such as: data form (table), layer (div)
Deng, mixing resource typically at least includes two or more monomer resources.
Page data output sub-module, arranges submodule with page resource and is connected, according to the company of client modules
Connect request and page resource arranges submodule to the data cell attribute facilities in webpage, generate page
The data in face.Page resource is divided into a lot of unit, and each data cell has independent id, is
The attributes such as no caching switch, Update Level and version information.Page data output sub-module ultimately generates page
The main frame in face and all data resources that need not client-cache, and return it to visitor by network
Family end module.
Client modules includes that data load submodule, Data Control submodule, data sub module stored, number
According to showing four submodules such as submodule.Wherein:
Data load submodule, are connected with Data Control submodule, are mainly used in sending client modules request,
In Connection Service end module, the main body frame of webpage of acquisition service end return, the data cell without caching
Hold, need the data cell of caching, webpage each data cell attribute information etc., and transferred to Data Control
Submodule is analyzed.
Data sub module stored, for needing the data cell of caching to carry out this locality to the webpage of WEB system
Change and store, and store the version information of data cell, to improve the access efficiency of webpage.
Different memory spaces is opened up in the website that Data Control submodule is different, it is simple to Data Control submodule
Carry out storage and the reading of data cell.Data cell for mixing resource is used for opening up independent space
Storage.As: for a table (data form) comprising picture and link.
Data Control submodule, loads submodule, data sub module stored, data display submodule with data
It is connected, is mainly used in loading submodule according to data and obtains webpage each data cell attribute information, analyze webpage
In whether there is a need to caching data cell;And be used for judging whether this locality exists the data cached list of described needs
Unit and the Update Level needing buffered data units;And control data loading submodule according to analyzing judged result
Loading to web data, controls the storage that data sub module stored is data cached to needs, controls data exhibition
Show the submodule displaying to web data.
Data Control submodule with the main of other submodules is alternately: one, controls data and loads submodule even
Connect server module and send the request of web page access;Two, the web data file that Analysis Service end returns;Three,
It is empty that the id of the data cell cached as required creates independent storage in client data sub module stored
Between;Four, the version information of comparison data unit;Five, data cell is stored to data sub module stored;
Six, data cell is read out from data sub module stored;Seven, Controling network page data or data cell
Show in a browser.
Data display subelement, and data fast with Data Control submodule load submodule and are connected, are used for loading
Data cell is in the main body frame from the webpage of service end acquisition request, and with without the data cell of caching
The webpage that content composition is complete, shows together.The result that user finally browses should be the complete page, including:
The data cell without caching that service end returns, and this locality read in client data sub module stored
The data cell of storage.
It addition, client modules can be connected by the Internet passage with server module, client modules each
Individual function can be run by multiple browser softwares such as the IE of general terminal and realize.Server module
Being generally operated at the server providing various network services, the function of its each module is run the most on the server
Realize.
In the foregoing description, data refer to the web page contents that user is to be browsed.
By the description of the present embodiment, the present invention program, it is to avoid traditional browser rs cache technology for
The web page resources of type all loads or the defect of the clean cut being all not loaded with.In existing skill
The page resource adding service end on the basis of art framework arranges Data Control of submodule and client
Module, it is achieved whether its web page resources of control that the WEB portal service provider of service end can be autonomous exists
Client caches, and mutual with reach to reduce between service end and client, the interface improving user is visited
Ask the purpose of speed.
The most current browser rs cache technology, owing to browser is present in the limitation of client, it is impossible to
Which is to need real-time update to know webpage that user desires access to, and which only need to be saved in client local cache
In district, and data cached when, can only according to the type clean cut of web page resources,
The most some type of web page resources or all cache, or all do not cache, underaction.And by we
The enforcement of case, service end WEB portal service provider can get involved its site resource in each client
Reasonable preservation behavior in, the most only WEB portal service provider just can accurately indicate each webpage
Whether resource caches and Update Level.Therefore this programme can not only greatly reduce client and service end mould
The mutual data traffic of block, alleviates the burden that data are brought to network and server in transmitting procedure, and
And do not affect user and browse and process data in client executing, shorten user and wait that data connection service device adds
Carry the time of entire Web page, improve the efficiency that user processes.
Above-described embodiment only be used for further illustrate the present invention a kind of WEB platform data caching method and
Its device, but the invention is not limited in embodiment, every technical spirit according to the present invention is implemented above
Any simple modification, equivalent variations and the modification that example is made, each falls within the protection domain of technical solution of the present invention
In.