CN106293675A - Static system resource loading method and device - Google Patents
Static system resource loading method and device Download PDFInfo
- Publication number
- CN106293675A CN106293675A CN201510309048.5A CN201510309048A CN106293675A CN 106293675 A CN106293675 A CN 106293675A CN 201510309048 A CN201510309048 A CN 201510309048A CN 106293675 A CN106293675 A CN 106293675A
- Authority
- CN
- China
- Prior art keywords
- static resource
- static
- resource
- data
- access
- 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.)
- Granted
Links
Landscapes
- Stored Programmes (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a kind of static system resource loading method, including: when receiving accessing page request, obtain the static resource data after just-ahead-of-time compilation;The static resource that described access data are corresponding is extracted from acquired static resource data;Load the static resource that extracted, complete the access of described access request correspondence page data passing through extracted static resource.Invention additionally discloses a kind of static system resource charger.The present invention improves the degree of optimization of static resource.
Description
Technical field
The present invention relates to field of computer technology, be related specifically to static system resource loading method and dress
Put.
Background technology
Along with the Internet exploitation and iteration speed are increasingly faster, it is more and more huger that internet site also becomes,
There is substantial amounts of static resource, the relation between static resource becomes intricate, carries to Developmental Engineer
Carry out a lot of trouble.At present, the process of static resource specifically includes that
1, SeaJS:SeaJS follows CMD specification, is a module loader being absorbed in Web browser,
The mode using lazyness to perform realizes.Its shortcoming is: 1 > packing spm is the most difficult, and new hand needs many
Practise cost;2 > cannot be updated static resource controlling;3 > cannot quickly realize version iteration issue with
Rollback.
2, RequireJS:RequireJS follows AMD specification, is the rings such as a support browser and Node
The module loader in border, uses the mode load-on module of pre-execution.Its shortcoming is: 1 > upset user
File loading sequence, it is possible to create some abnormal conditions;2 > cannot be updated static resource controlling;
3 > cannot quickly realize version iteration to issue and rollback.
To sum up, existing static resource processing mode web static resource can be loaded play certain excellent
Change, but the degree of optimization of static resource is low.
Summary of the invention
The embodiment of the present invention provides a kind of static system resource loading method and device, it is intended to solve existing
Web static resource can be loaded and play certain optimization by static resource processing mode, but static resource
The problem that degree of optimization is low.
For achieving the above object, the embodiment of the present invention proposes a kind of static system resource loading method, including:
When receiving accessing page request, obtain the static resource data after just-ahead-of-time compilation;
The static resource that described access data are corresponding is extracted from acquired static resource data;
Load the static resource that extracted, complete described access request pair passing through extracted static resource
Answer the access of page data.
To achieve these goals, the embodiment of the present invention it is further proposed that a kind of static system resource loads
Device, including:
Acquisition module, for when receiving accessing page request, obtains the static resource after just-ahead-of-time compilation
Data;
Extraction module, for extracting corresponding quiet of described access data from acquired static resource data
State resource;
Load-on module, for loading the static resource that extracted, completes passing through extracted static resource
The access of described access request correspondence page data.
The present invention is by the dependence of the whole static resource of precompile in advance, it is to avoid existing static resource
The problem that processing mode degree of optimization is low.Improve the degree of optimization of static resource.
Accompanying drawing explanation
Fig. 1 is the hardware structure schematic diagram involved by embodiment of the present invention static system resource charger;
Fig. 2 is the schematic flow sheet of the first embodiment of present system static resource loading method;
Fig. 3 is the refinement schematic flow sheet that the present invention is compiled processing an embodiment in advance to static resource;
Fig. 4 is the static state that the present invention extracts that from acquired static resource data described access data are corresponding
The refinement schematic flow sheet of resource one embodiment;
Fig. 5 is the schematic flow sheet of the second embodiment of present system static resource loading method;
Fig. 6 is the schematic flow sheet of the 3rd embodiment of present system static resource loading method;
Fig. 7 is the schematic flow sheet of the 4th embodiment of present system static resource loading method;
Fig. 8 is the high-level schematic functional block diagram of the first embodiment of present system static resource charger;
Fig. 9 is the high-level schematic functional block diagram of the second embodiment of present system static resource charger;
Figure 10 is the refinement high-level schematic functional block diagram of extraction module one embodiment in Fig. 8;
Figure 11 is the high-level schematic functional block diagram of the 3rd embodiment of present system static resource charger;
Figure 12 is the high-level schematic functional block diagram of the 4th embodiment of present system static resource charger;
Figure 13 is the high-level schematic functional block diagram of the 5th embodiment of present system static resource charger.
The realization of the object of the invention, functional characteristics and advantage will in conjunction with the embodiments, do referring to the drawings further
Explanation.
Detailed description of the invention
Should be appreciated that specific embodiment described herein, only in order to explain the present invention, is not used to limit
Determine the present invention.
The primary solutions of the embodiment of the present invention is: when receiving accessing page request, obtains in advance
Static resource data after compiling;Static resource data determined by according to obtains the deployment road of static resource
Footpath and dependence;Dispose path and dependence according to described static resource provide from acquired static state
Source data is extracted the static resource that described access data are corresponding;Load the static resource extracted, with logical
Cross extracted static resource and complete the access of described access request correspondence page data.By prelisting in advance
Translate the dependence of whole static resource, it is to avoid existing static resource low the asking of processing mode degree of optimization
Topic.Improve the degree of optimization of static resource.
Due to existing static resource processing mode web static resource can be loaded play certain excellent
Change, but the problem that the degree of optimization of static resource is low.
Embodiment of the present invention framework one static system resource charger, this static system resource charger
Dependence by the whole static resource of precompile in advance, it is to avoid existing static resource processing mode is excellent
The problem that change degree is low.Improve the degree of optimization of static resource.
Wherein, the present embodiment static system resource charger can be carried on PC end, it is also possible to is carried on
Mobile phone, panel computer etc. can use the electric terminal of the network applications such as browser.This static system resource
Hardware structure involved by charger can be as shown in Figure 1.
Fig. 1 shows the hardware structure involved by embodiment of the present invention static system resource charger.Such as figure
Shown in 1, the hardware involved by described static system resource charger includes: processor 301, such as CPU,
Network interface 304, user interface 303, memorizer 305, communication bus 302.Wherein, communication bus 302
For realizing in this information push platform the connection communication between each building block.User interface 303 can wrap
Include the assemblies such as display screen (Display), keyboard (Keyboard), mouse, for receiving user's input
Information, and the information transmission of reception is processed to processor 305.Display screen can be LCD display,
LED display, it is also possible to for touch screen, need display for display system static resource charger
Data, the such as operation such as web page access data, static system resource loading interface.Optional user interface 303
The wireline interface of standard, wave point can also be included.Network interface 304 optionally can include standard
Wireline interface, wave point (such as WI-FI interface).Memorizer 305 can be high-speed RAM memorizer, also
Can be stable memorizer (non-volatile memory), such as disk memory.Memorizer 305 can
That selects can also is that the storage device independent of aforementioned processor 301.As it is shown in figure 1, calculate as a kind of
The memorizer 305 of machine storage medium can include operating system, network communication module, Subscriber Interface Module SIM
And static system resource loading procedure.
In the hardware involved by the static system resource charger shown in Fig. 1, network interface 304 is main
It is used for connecting application platform, carries out data communication with application platform;User interface 303 is mainly used in even
Connect client, carry out data communication with client, receive information and the instruction of client input;And process
Device 301 may be used for calling the static system resource loading procedure of storage in memorizer 305, and perform with
Lower operation:
When receiving accessing page request, obtain the static resource data after just-ahead-of-time compilation;
The static resource that described access data are corresponding is extracted from acquired static resource data;
Load the static resource that extracted, complete described access request pair passing through extracted static resource
Answer the access of page data.
Further, in one embodiment, the system of storage during processor 301 calls memorizer 305
Static resource loading procedure can perform following operation:
It is compiled static resource processing;
In compilation process, set up a static resource relation table, record the deployment road of each static resource
Footpath and dependence;
After compiling completes, generate the static resource data after compiling.
Further, in one embodiment, the system of storage during processor 301 calls memorizer 305
Static resource loading procedure can perform following operation:
Judge whether page access corresponding to described access request runs in rear end;
When running in rear end, determine the use information of described page access correspondence assembly;
Use information according to described assembly and the deployment path of described static resource and dependence are from being obtained
The static resource data taken is dispatched the static resource of correspondence, renders for front end back page required quiet
State resource.
Further, in one embodiment, the system of storage during processor 301 calls memorizer 305
Static resource loading procedure can perform following operation:
When running in front end, determine the interbehavior information that described access request is corresponding;
According to described interbehavior information and the deployment path of described static resource and dependence from acquired
Static resource data in extract correspondence static resource, to complete the access of front end page.
Further, in one embodiment, the system of storage during processor 301 calls memorizer 305
Static resource loading procedure can perform following operation:
Obtain the use information of static resource;
The static resource that use information retrieval according to described static resource is associated;
Automatically the static resource being associated is merged.
Further, in one embodiment, the system of storage during processor 301 calls memorizer 305
Static resource loading procedure can perform following operation:
Obtain the hash value of static resource respective file content;
The version updating of static resource is controlled according to described hash value.
Further, in one embodiment, the system of storage during processor 301 calls memorizer 305
Static resource loading procedure can perform following operation:
In static resource running, determine the configuration information that running static resource is corresponding;
Receive the change directive of described configuration information, according to described change directive change described configuration information with
The access right of change static resource controls.
The present embodiment, according to such scheme, by the dependence of the whole static resource of precompile in advance, is kept away
Exempt from the problem that existing static resource processing mode degree of optimization is low.Improve the degree of optimization of static resource.
Based on above-mentioned hardware structure, present system static resource loading method embodiment is proposed.
As in figure 2 it is shown, propose the first embodiment of the present invention a kind of static system resource loading method, institute
State static system resource loading method to include:
Step S10, when receiving accessing page request, obtains the static resource data after just-ahead-of-time compilation;
In the present embodiment, it is compiled static resource in advance processing.With reference to Fig. 3, described in advance to quiet
The process that state resource is compiled processing includes:
Step S01, is compiled static resource processing;
Step S02, in compilation process, sets up a static resource relation table, records each static resource
Deployment path and dependence;
Step S03, after compiling completes, generates the static resource data after compiling.
Being compiled static resource processing, carry out pretreatment including many static resources, url process is (such as,
Add md5 stamp), add CDN prefix, optimize (compress, merging etc.), generate Sourcemap etc..
In compilation process, system can scan static resource, sets up a static resource relation table, records each
The information such as the deployment path of static resource and dependence, by static resource being compiled process,
Static resource data after compiling.
Concrete, the embodiment of the present invention is grammer and the rule that website engineer provides statement dependence,
Static resource can be scanned in the compilation phase, set up a static resource relation table, record each static resource
Deployment path and the information such as dependence.Dependence announcement procedure includes following several example:
1, in html, statement relies on: uses in the index.html of project and annotates statement dependence:
<--
@require demo.js
Qrequire”demo.css”
-->
In SourceMap then it can be seen that;
{
”demo.css”:{
" uri ": "/static/css/demo_7defa41.css ",
”type”:”css”
,
”demo.js”:{
" uri ": "/static/css/demo_33c5143.js ",
" type ": " js ",
”deps”:[”demo.css”]
,
”index.html”:{
" uri ": "/index.html ",
" type ": " html ",
" deps ": [" demo.js ", " demo.css "]
}
,
”pkg”:{}
}
2, in js, statement relies on: support the require function in js file, or the@require of master clock
The dependence of field mark, these analyzing and processing are the most effective to the script label substance of html.
//demo.js
/**
*@require demo.css
*@require list.js
*/
Var $=require (' jquery ');
SourceMap then can be seen that
{
”res”:{
…
”demo.js”:{
" uti ": "/static/js/demo_33c5143.js ",
" type ": " js ",
" deps ": [" demo.css ", " list.js ", " jquery "]
,
…
}
”pkg”:{}
}
3, in css, statement relies on: support css file, depending on of the@require field mark in annotation
The relation of relying, these analyzing and processing are the most effective to the style label substance of html.
//demo.js
/**
*@require demo.css
*@require list.js
*/
Var $=require (' jquery ');
SourceMap then can be seen that
{
”res”:{
…
”demo.js”:{
" uti ": "/static/js/demo_33c5143.js ",
" type ": " js ",
" deps ": [" demo.css ", " list.js ", " jquery "]
,
…
}
”pkg”:{}
}
Receive accessing page request, when receiving accessing page request, obtain the static state after just-ahead-of-time compilation
Resource data.Described accessing page request is preferably web page access request, and in the present invention, other are implemented
Also can also is that other kinds of accessing page request in example, this is no longer going to repeat them.
Step S20, extracts the static money that described access data are corresponding from acquired static resource data
Source;
Static resource institute data after described just-ahead-of-time compilation, extract static resource deployment path and
Dependence, i.e. obtains the scheduling logic of static resource.Extracting the deployment path of static resource and depending on
After the relation of relying, deployment path and dependence according to described static resource are from acquired static resource number
According to the static resource that middle extraction described access data are corresponding.
Preferably, with reference to Fig. 4, described from acquired static resource data, extract described access data pair
The process of the static resource answered may include that
Step S21, according to determined by static resource data obtain static state deployment path and dependence;
Step S22, deployment path and dependence according to described static resource are from acquired static resource
The static resource that data are corresponding is accessed described in extracting data.
Concrete, it is judged that whether page access corresponding to described access request runs in rear end, transports in rear end
During row, determine the use information of described page access correspondence assembly, according to the use information of described assembly and
The path of disposing of described static resource is dispatched corresponding with dependence from acquired static resource data
Static resource, renders required static resource for front end back page;When running in front end, determine institute
State the interbehavior information that access request is corresponding;According to described interbehavior information and described static resource
Dispose path and dependence extracts corresponding static resource, with complete from acquired static resource data
Become the access of front end page.
Step S30, loads the static resource that extracted, completes described visit passing through extracted static resource
The access of the corresponding page data of the request of asking.
In the present embodiment, after extracting the static resource that described access request is corresponding, load and extracted
Static resource, complete the visit of described access request correspondence page data passing through extracted static resource
Ask.Such as, page access, when rear end is run, dispatches static resource according to assembly service condition, for
Front end back page renders the resource of needs, is realized the access of page data by scheduling static resource.
By the static resources such as JS, CSS of webpage are integrated, engineer can be helped quickly to develop height
The website of performance, Speeding up development efficiency, improves system stability.
After static resource in system has taken over project, it is known that the ruuning situation of static resource and
Dependence, then can accomplish to be page on-demand loading static resource automatically, such as:
Content in Sidebar.tpl is as follows:
<!—
@require”common:ui/dialog/dialog/css”
-->
<a id=" btn-navbar " class=" btn-navbar>
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
</a>
{script}
Var sidebar=require (" common:ui/dialog/dialog/js ");
sidebar.run();
{/script}
{script}
$(’a.btn-navbar’).click(function(){
Require/async (' common:ui/dialog/dialog.async.js ',
function(dialog){dialog.run();
});
});
{/script}
After compiling project, automation tools can analyze dependence, and generates SourceMap, as follows:
”common:widget/sidebar/sidebar.tpl”{
" uri ": " common/widget/sidebar/sidebar.tpl ",
" type ": " tpl ",
”extras”:{
”async”:[
”common:ui/dialog.async.js”
]
,
”deps”:[
" common:ui/dialog/dialog.js ",
”common:ui/dialog/dialog.css”
]
}
After sidebar is called, system by inquiry SourceMap it is known that current sidebar
Synchronizing to rely on sidebar.js, sidebar.css, asynchronous dependence sdebar.async.js, at html to be exported
Above, generating the outer chain of static resource, it is as follows that we obtain final html:
<link rel=" stylesheet " href="/static/ui/dialog/dialog_7defa41.css ">
<a id=" btn-navbar=" btn-navbar ">
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
</a>
< script type=" text/javascript "
Src=”/static/common/ui/dialog/$12cd4.js”></script>
<script type=" text/javascript ">
require.resourceMap({
”res”:{
”common:ui/dialog/dialog.asyunc.js”:{
”url”:/satic/common/ui/dialog/dialog.async_449e169.js”
}
}
});
</script>
<script rype=" text/javascript ">
Var sidebar=require (" common:ui/dialog/dialog.js ");
sidebar.run();
$(’a.btn-navbar’).click(funcition(){
Require.async (' common:ui/dialog/dialog/async.js ',
function(dialog){dialog.run();
});
});
</script>
The most visible, rear module framework is generated to bottom the page by unified for the script url of synchronization, will
Css url is unified to be generated in head, and for asynchronous registration reSourceMap code, framework can pass through { script}
The all script of the page collected by label, and unified management in order output script are to relevant position.
The present embodiment is by the dependence of the whole static resource of precompile in advance, it is to avoid existing static money
The problem that source processing mode degree of optimization is low.Improve the degree of optimization of static resource.
Further, first embodiment based on said system static resource loading method, the present invention is proposed
The second embodiment.As it is shown in figure 5, described method can also include:
Step S40, obtains the use information of static resource;
Step S50, the static resource being associated according to the use information retrieval of described static resource;
Step S60, merges the static resource being associated automatically.
In the present embodiment, the use information of static resource is obtained;Use letter according to described static resource
Breath extracts the static resource being associated;Automatically the static resource being associated is merged.Concrete process is: root
The data used according to static resource on product line, are automatically performed static resource merging work, complete to engineer
All-transparent, solve manual maintenance gets rid of waste resource, unsustainable, high in cost of production problem the most in time.
The most also it may also is that according to the use information of static resource, automatically get rid of one
Some discarded static resource data, such as, get rid of the most expired static resource perhaps long (1 year or half a year
Deng) untapped static resource data.
The static resource being associated, by obtaining the use information of static resource, is merged by the present embodiment automatically,
Improve reasonability and the effectiveness of static resource management.
Further, first embodiment based on said system static resource loading method, the present invention is proposed
The 3rd embodiment.As shown in Figure 6, described method can also include:
Step S70, obtains the hash value of static resource respective file content;
Step S80, controls the version updating of static resource according to described hash value.
In the present embodiment, system uses hash value based on file content to control the version of static resource
Update, the most as follows:
<script type=”text/javascript”src=”a_8244e91.js”></script>
This string character of wherein _ 8244e91 is that the file content according to a.js carries out hash computing and obtains, only
Having file content to change just and have change, the benefit of do so has:
A.js on line is not that file of the same name covers, but the redundancy of filename+hash, it is possible to first line
Upper static resource, in the html page of reaching the standard grade, the problem that there is not gap;Encounter problems rollback version time
Wait, it is not necessary to rollback a.js, only need the rollback page.Owing to static resource version number is file content
Hash, the most all static resources can open permanent strong caching, and the file that only have updated content just can delay
Depositing inefficacy, Buffer Utilization increases.New file, a literary composition can be produced on line after amendment static resource
The corresponding version of part, is attacked thus without by structure CDN caching form.System can be in compiling
Telltale mark (url) in identification file during compile, the hash of calculating respective file, and automatically
Replace with ' filename+hash ', it is not necessary to engineer's manual modification.
Further, first embodiment based on said system static resource loading method, the present invention is proposed
The 4th embodiment.As it is shown in fig. 7, described method can also include:
Step S90, in static resource running, determines the configuration letter that running static resource is corresponding
Breath;
Step S100, receives the change directive of described configuration information, according to the change of described change directive
Configuration information controls with the access right of change static resource.
In the present embodiment, static resource can be done and control further to reach the effect that classification is issued by system
Really, mainly include following two pieces of Core Features, feature flags, be used for controlling static state corresponding to feature
Whether resource loads;Feature flippers, can control feature flexibly, be not only on or off,
Can accomplish that being similar to ' 3% user can access this function, similar effect open to internal all employees.Logical
We can be readily implemented by one New function of website orientation by this function only to portion to cross above control
Divide user-accessible, when open to all users after perfect in shape and function, a direct key if function goes wrong
Rollback, similar code in the project is as follows:
{if$config.some eq’Fred’}
Do something new and amazing here.
{elseif$config.some eq’Wilma’}
Do the current boring stuff.
{else}
Whatever you are.
Config.some operationally can be intervened by system according to configuration, it is achieved the visit to static resource
Asking the control of control, the configuration (feature flag) during by running controls static resource, it is also possible to
Support the mode of trunk exploitation, reach faster iteration speed.The generation related in each embodiment above
Code is only the citing of an embodiment, and in other embodiments, other codes or implementation do not exist
This illustrates one by one, but is also included within embodiment of the present invention.
Accordingly, the first embodiment of present system static resource charger is proposed.With reference to Fig. 8, institute
State static system resource charger and include acquisition module 10, extraction module 20 and load-on module 30.
Described acquisition module 10, for when receiving accessing page request, obtain after just-ahead-of-time compilation is quiet
State resource data;
In the present embodiment, it is compiled static resource in advance processing.With reference to Fig. 9, described device also wraps
Include:
Collector 40, for being compiled process to static resource;
Processing module 50, in compilation process, sets up a static resource relation table, records each
The deployment path of static resource and dependence;
Generation module 60, for after compiling completes, generates the static resource data after compiling.
Being compiled static resource processing, carry out pretreatment including many static resources, url process is (such as,
Add md5 stamp), add CDN prefix, optimize (compress, merging etc.), generate Sourcemap etc..
In compilation process, system can scan static resource, sets up a static resource relation table, records each
The information such as the deployment path of static resource and dependence, by static resource being compiled process,
Static resource data after compiling.
Concrete, the embodiment of the present invention is grammer and the rule that website engineer provides statement dependence,
Static resource can be scanned in the compilation phase, set up a static resource relation table, record each static resource
Deployment path and the information such as dependence.Dependence announcement procedure includes following several example:
1, in html, statement relies on: uses in the index.html of project and annotates statement dependence:
<--
@require demo.js
Qrequire”demo.css”
-->
In SourceMap then it can be seen that;
{
”demo.css”:{
" uri ": "/static/css/demo_7defa41.css ",
”type”:”css”
,
”demo.js”:{
" uri ": "/static/css/demo_33c5143.js ",
" type ": " js ",
”deps”:[”demo.css”]
,
”index.html”:{
" uri ": "/index.html ",
" type ": " html ",
" deps ": [" demo.js ", " demo.css "]
}
,
”pkg”:{}
}
2, in js, statement relies on: support the require function in js file, or the@require of master clock
The dependence of field mark, these analyzing and processing are the most effective to the script label substance of html.
//demo.js
/**
*@require demo.css
*@require list.js
*/
Var $=require (' jquery ');
SourceMap then can be seen that
{
”res”:{
…
”demo.js”:{
" uti ": "/static/js/demo_33c5143.js ",
" type ": " js ",
" deps ": [" demo.css ", " list.js ", " jquery "]
,
…
}
”pkg”:{}
}
3, in css, statement relies on: support css file, depending on of the@require field mark in annotation
The relation of relying, these analyzing and processing are the most effective to the style label substance of html.
//demo.js
/**
*@require demo.css
*@require list.js
*/
Var $=require (' jquery ');
SourceMap then can be seen that
{
”res”:{
…
”demo.js”:{
" uti ": "/static/js/demo_33c5143.js ",
" type ": " js ",
" deps ": [" demo.css ", " list.js ", " jquery "]
,
…
}
”pkg”:{}
}
Receive accessing page request, when receiving accessing page request, obtain the static state after just-ahead-of-time compilation
Resource data.Described accessing page request is preferably web page access request, and in the present invention, other are implemented
Also can also is that other kinds of accessing page request in example, this is no longer going to repeat them.
Described extraction module 20, for extracting described access data pair from acquired static resource data
The static resource answered;
Static resource institute data after described just-ahead-of-time compilation, extract static resource deployment path and
Dependence, i.e. obtains the scheduling logic of static resource.Extracting the deployment path of static resource and depending on
After the relation of relying, deployment path and dependence according to described static resource are from acquired static resource number
According to the static resource that middle extraction described access data are corresponding.Preferably, according to determined by static resource number
According to the deployment path and the dependence that obtain static state;Deployment path according to described static resource and dependence are closed
System extracts the static resource that described access data are corresponding from acquired static resource data.
Concrete, with reference to Figure 10, described extraction module 20 includes: judging unit 21, is used for judging institute
State whether page access corresponding to access request runs in rear end;Determine unit 22, for running in rear end
Time, determine the use information of described page access correspondence assembly;Extraction unit 23, for according to described group
The use information of part and the deployment path of described static resource and dependence are from acquired static resource number
According to the static resource that middle scheduling is corresponding, render required static resource for front end back page;In front end
During operation, determine the interbehavior information that described access request is corresponding;According to described interbehavior information and
The path of disposing of described static resource is extracted corresponding with dependence from acquired static resource data
Static resource, to complete the access of front end page.
Described load-on module 30, for loading the static resource extracted, to pass through extracted static money
Source completes the access of described access request correspondence page data.
In the present embodiment, after extracting the static resource that described access request is corresponding, load and extracted
Static resource, complete the visit of described access request correspondence page data passing through extracted static resource
Ask.Such as, page access, when rear end is run, dispatches static resource according to assembly service condition, for
Front end back page renders the resource of needs, is realized the access of page data by scheduling static resource.
By the static resources such as JS, CSS of webpage are integrated, engineer can be helped quickly to develop height
The website of performance, Speeding up development efficiency, improves system stability.
After static resource in system has taken over project, it is known that the ruuning situation of static resource and
Dependence, then can accomplish to be page on-demand loading static resource automatically, such as:
Content in Sidebar.tpl is as follows:
<!—
@require”common:ui/dialog/dialog/css”
-->
<a id=" btn-navbar " class=" btn-navbar>
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
</a>
{script}
Var sidebar=require (" common:ui/dialog/dialog/js ");
sidebar.run();
{/script}
{script}
$(’a.btn-navbar’).click(function(){
Require/async (' common:ui/dialog/dialog.async.js ',
function(dialog){dialog.run();
});
});
{/script}
After compiling project, automation tools can analyze dependence, and generates SourceMap, as follows:
”common:widget/sidebar/sidebar.tpl”{
" uri ": " common/widget/sidebar/sidebar.tpl ",
" type ": " tpl ",
”extras”:{
”async”:[
”common:ui/dialog.async.js”
]
,
”deps”:[
" common:ui/dialog/dialog.js ",
”common:ui/dialog/dialog.css”
]
}
After sidebar is called, system by inquiry SourceMap it is known that current sidebar
Synchronizing to rely on sidebar.js, sidebar.css, asynchronous dependence sdebar.async.js, at html to be exported
Above, generating the outer chain of static resource, it is as follows that we obtain final html:
<link rel=" stylesheet " href="/static/ui/dialog/dialog_7defa41.css ">
<a id=" btn-navbar=" btn-navbar ">
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
<span class=”icon-bar”></span>
</a>
< script type=" text/javascript "
Src=”/static/common/ui/dialog/$12cd4.js”></script>
<script type=" text/javascript ">
require.resourceMap({
”res”:{
”common:ui/dialog/dialog.asyunc.js”:{
”url”:/satic/common/ui/dialog/dialog.async_449e169.js”
}
}
});
</script>
<script rype=" text/javascript ">
Var sidebar=require (" common:ui/dialog/dialog.js ");
sidebar.run();
$(’a.btn-navbar’).click(funcition(){
Require.async (' common:ui/dialog/dialog/async.js ',
function(dialog){dialog.run();
});
});
</script>
The most visible, rear module framework is generated to bottom the page by unified for the script url of synchronization, will
Css url is unified to be generated in head, and for asynchronous registration reSourceMap code, framework can pass through { script}
The all script of the page collected by label, and unified management in order output script are to relevant position.
The present embodiment is by the dependence of the whole static resource of precompile in advance, it is to avoid existing static money
The problem that source processing mode degree of optimization is low.Improve the degree of optimization of static resource.
Further, the second embodiment based on said system static resource charger, the present invention is proposed
3rd embodiment of device.As shown in figure 11, described device can also include merging module 70,
Described acquisition module 10, is additionally operable to obtain the use information of static resource;
Described extraction unit 23, be additionally operable to according to described static resource use information retrieval be associated quiet
State resource;
Described merging module 70, for automatically merging the static resource being associated.
In the present embodiment, the use information of static resource is obtained;Use letter according to described static resource
Breath extracts the static resource being associated;Automatically the static resource being associated is merged.Concrete process is: root
The data used according to static resource on product line, are automatically performed static resource merging work, complete to engineer
All-transparent, solve manual maintenance gets rid of waste resource, unsustainable, high in cost of production problem the most in time.
The most also it may also is that according to the use information of static resource, automatically get rid of one
Some discarded static resource data, such as, get rid of the most expired static resource perhaps long (1 year or half a year
Deng) untapped static resource data.
The static resource being associated, by obtaining the use information of static resource, is merged by the present embodiment automatically,
Improve reasonability and the effectiveness of static resource management.
Further, the 3rd embodiment based on said system static resource charger, the present invention is proposed
4th embodiment of device.As shown in figure 12, described device can also include: control module 80,
Described acquisition module 10, is additionally operable to obtain the hash value of static resource respective file content;
Described control 80, for controlling the version updating of static resource according to described hash value.
In the present embodiment, system uses hash value based on file content to control the version of static resource
Update, the most as follows:
<script type=”text/javascript”src=”a_8244e91.js”></script>
This string character of wherein _ 8244e91 is that the file content according to a.js carries out hash computing and obtains, only
Having file content to change just and have change, the benefit of do so has:
A.js on line is not that file of the same name covers, but the redundancy of filename+hash, it is possible to first line
Upper static resource, in the html page of reaching the standard grade, the problem that there is not gap;Encounter problems rollback version time
Wait, it is not necessary to rollback a.js, only need the rollback page.Owing to static resource version number is file content
Hash, the most all static resources can open permanent strong caching, and the file that only have updated content just can delay
Depositing inefficacy, Buffer Utilization increases.New file, a literary composition can be produced on line after amendment static resource
The corresponding version of part, is attacked thus without by structure CDN caching form.System can be in compiling
Telltale mark (url) in identification file during compile, the hash of calculating respective file, and automatically
Replace with ' filename+hash ', it is not necessary to engineer's manual modification.
Further, the 4th embodiment based on said system static resource charger, the present invention is proposed
5th embodiment of device.As shown in figure 13, described device can also include: receiver module 90 and more
Change module 100,
Described determine unit 22, be additionally operable in static resource running, determine that running static state provides
The configuration information that source is corresponding;
Described receiver module 90, for receiving the change directive of described configuration information;
Described change module 100, for changing described configuration information to change static state according to described change directive
The access right of resource controls.
In the present embodiment, static resource can be done and control further to reach the effect that classification is issued by system
Really, mainly include following two pieces of Core Features, feature flags, be used for controlling static state corresponding to feature
Whether resource loads;Feature flippers, can control feature flexibly, be not only on or off,
Can accomplish that being similar to ' 3% user can access this function, similar effect open to internal all employees.Logical
We can be readily implemented by one New function of website orientation by this function only to portion to cross above control
Divide user-accessible, when open to all users after perfect in shape and function, a direct key if function goes wrong
Rollback, similar code in the project is as follows:
{if$config.some eq’Fred’}
Do something new and amazing here.
{elseif$config.some eq’Wilma’}
Do the current boring stuff.
{else}
Whatever you are.
Config.some operationally can be intervened by system according to configuration, it is achieved the visit to static resource
Asking the control of control, the configuration (feature flag) during by running controls static resource, it is also possible to
Support the mode of trunk exploitation, reach faster iteration speed.The generation related in each embodiment above
Code is only the citing of an embodiment, and in other embodiments, other codes or implementation do not exist
This illustrates one by one, but is also included within embodiment of the present invention.
It should be noted that in this article, term " include ", " comprising " or its any other variant
Be intended to comprising of nonexcludability so that include the process of a series of key element, method, article or
Person's device not only includes those key elements, but also includes other key elements being not expressly set out, or also
Including the key element intrinsic for this process, method, article or device.In the feelings not having more restriction
Under condition, statement " including ... " key element limited, it is not excluded that include this key element process,
Method, article or device there is also other identical element.
The invention described above embodiment sequence number, just to describing, does not represent the quality of embodiment.
Through the above description of the embodiments, those skilled in the art is it can be understood that arrive above-mentioned
Embodiment method can add the mode of required general hardware platform by software and realize, naturally it is also possible to logical
Cross hardware, but a lot of in the case of the former is more preferably embodiment.Based on such understanding, the present invention's
The part that prior art is contributed by technical scheme the most in other words can be with the form body of software product
Revealing to come, this computer software product is stored in a storage medium (such as ROM/RAM, magnetic disc, light
Dish) in, including some instructions with so that a station terminal equipment (can be mobile phone, computer, service
Device, or the network equipment etc.) perform the method described in each embodiment of the present invention.
Claims (14)
1. a static system resource loading method, it is characterised in that including:
When receiving accessing page request, obtain the static resource data after just-ahead-of-time compilation;
The static resource that described access data are corresponding is extracted from acquired static resource data;
Load the static resource that extracted, complete described access request pair passing through extracted static resource
Answer the access of page data.
2. the system as claimed in claim 1 static resource loading method, it is characterised in that described in obtain
Before taking the step of the static resource data after just-ahead-of-time compilation, also include:
It is compiled static resource processing;
In compilation process, set up a static resource relation table, record the deployment road of each static resource
Footpath and dependence;
After compiling completes, generate the static resource data after compiling.
3. the system as claimed in claim 1 static resource loading method, it is characterised in that described from
The step extracting static resource corresponding to described access data in acquired static resource data includes:
Judge whether page access corresponding to described access request runs in rear end;
When running in rear end, determine the use information of described page access correspondence assembly;
Use information according to described assembly and the deployment path of described static resource and dependence are from being obtained
The static resource data taken is dispatched the static resource of correspondence, renders for front end back page required quiet
State resource.
4. static system resource loading method as claimed in claim 3, it is characterised in that described judgement
Whether page access corresponding to described access request, after the step that rear end is run, also includes;
When running in front end, determine the interbehavior information that described access request is corresponding;
According to described interbehavior information and the deployment path of described static resource and dependence from acquired
Static resource data in extract correspondence static resource, to complete the access of front end page.
5. the static system resource loading method as described in any one of Claims 1-4, its feature exists
In, described method also includes:
Obtain the use information of static resource;
The static resource that use information retrieval according to described static resource is associated;
Automatically the static resource being associated is merged.
6. the static system resource loading method as described in any one of Claims 1-4, its feature exists
In, described method also includes:
Obtain the hash value of static resource respective file content;
The version updating of static resource is controlled according to described hash value.
7. the static system resource loading method as described in any one of Claims 1-4, its feature exists
In, described method also includes:
In static resource running, determine the configuration information that running static resource is corresponding;
Receive the change directive of described configuration information, according to described change directive change described configuration information with
The access right of change static resource controls.
8. a static system resource charger, it is characterised in that including:
Acquisition module, for when receiving accessing page request, obtains the static resource after just-ahead-of-time compilation
Data;
Extraction module, for extracting corresponding quiet of described access data from acquired static resource data
State resource;
Load-on module, for loading the static resource that extracted, completes passing through extracted static resource
The access of described access request correspondence page data.
9. static system resource charger as claimed in claim 8, it is characterised in that described dress
Put and also include:
Collector, for being compiled process to static resource;
Processing module, in compilation process, sets up a static resource relation table, records each quiet
The deployment path of state resource and dependence;
Generation module, for after compiling completes, generates the static resource data after compiling.
10. static system resource charger as claimed in claim 8, it is characterised in that described in carry
Delivery block includes:
Judging unit, for judging whether page access corresponding to described access request runs in rear end;
Determine unit, in time running in rear end, determine the use information of described page access correspondence assembly;
Extraction unit, for the deployment path according to the uses information of described assembly and described static resource with
Dependence dispatches the static resource of correspondence from acquired static resource data, for front end back page
Render required static resource.
11. static system resource chargers as claimed in claim 10, it is characterised in that described really
Cell, when being additionally operable to run in front end, determines the interbehavior information that described access request is corresponding;
Described extraction unit, is additionally operable to the deployment road according to described interbehavior information and described static resource
Footpath and dependence extract the static resource of correspondence from acquired static resource data, to complete front end
The access of the page.
12. static system resource chargers as claimed in claim 10, it is characterised in that described dress
Put and also include merging module,
Described acquisition module, is additionally operable to obtain the use information of static resource;
Described extraction unit, is additionally operable to the static state using information retrieval to be associated according to described static resource
Resource;
Described merging module, for automatically merging the static resource being associated.
13. static system resource chargers as claimed in claim 10, it is characterised in that described dress
Put and also include receiver module and change module,
Described determine unit, be additionally operable in static resource running, determine running static resource
Corresponding configuration information;
Described receiver module, for receiving the change directive of described configuration information;
Described change module, for changing described configuration information with change static state money according to described change directive
The access right in source controls.
The 14. static system resource chargers as described in any one of claim 8 to 13, its feature exists
In, described device also includes control module,
Described acquisition module, is additionally operable to obtain the hash value of static resource respective file content;
Described control module, for controlling the version updating of static resource according to described hash value.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510309048.5A CN106293675B (en) | 2015-06-08 | 2015-06-08 | System static resource loading method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510309048.5A CN106293675B (en) | 2015-06-08 | 2015-06-08 | System static resource loading method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106293675A true CN106293675A (en) | 2017-01-04 |
CN106293675B CN106293675B (en) | 2020-12-25 |
Family
ID=57658697
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201510309048.5A Active CN106293675B (en) | 2015-06-08 | 2015-06-08 | System static resource loading method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106293675B (en) |
Cited By (15)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106933965A (en) * | 2017-02-08 | 2017-07-07 | 福建省华渔教育科技有限公司 | The method of static resource request |
CN107169000A (en) * | 2017-03-31 | 2017-09-15 | 武汉斗鱼网络科技有限公司 | Static resource dissemination method and device |
CN107341038A (en) * | 2017-07-26 | 2017-11-10 | 成都三零盛安信息***有限公司 | Compatible processing method, device and electronic equipment |
CN107370791A (en) * | 2017-06-23 | 2017-11-21 | 微梦创科网络科技(中国)有限公司 | The method and system of filename in automatic synchronization renewal content distributing network |
CN107436787A (en) * | 2017-07-31 | 2017-12-05 | 腾讯科技(深圳)有限公司 | Method for processing resource, device, storage medium and electronic installation |
CN107748689A (en) * | 2017-10-19 | 2018-03-02 | 阿里巴巴集团控股有限公司 | A kind of web page display method and apparatus |
CN108287704A (en) * | 2017-01-10 | 2018-07-17 | 北大方正集团有限公司 | The method and system that web front-end exploration project is built |
CN108416029A (en) * | 2018-03-09 | 2018-08-17 | 深圳市富途网络科技有限公司 | A kind of static resource update method and system |
CN109634654A (en) * | 2018-12-04 | 2019-04-16 | 北京马上慧科技术有限公司 | A kind of page packaging method, device, system, computer equipment and storage medium |
CN109885791A (en) * | 2019-01-03 | 2019-06-14 | 深圳壹账通智能科技有限公司 | A kind of front end page access method, device and electronic equipment |
CN110109664A (en) * | 2018-10-18 | 2019-08-09 | 神思旭辉医疗信息技术有限责任公司 | A kind of integrated system and method for the page |
CN110196724A (en) * | 2018-08-17 | 2019-09-03 | 平安科技(深圳)有限公司 | File loading method, terminal, server, computer equipment and storage medium |
CN110244975A (en) * | 2018-03-08 | 2019-09-17 | 北京京东尚科信息技术有限公司 | A kind of generation method and device of static resource version number |
CN113515328A (en) * | 2020-04-09 | 2021-10-19 | 北京沃东天骏信息技术有限公司 | Page rendering method and device, electronic equipment and storage medium |
CN118069950A (en) * | 2024-04-24 | 2024-05-24 | 安徽省交通规划设计研究总院股份有限公司 | Webview characteristic-based method, webview characteristic-based device, webview characteristic-based equipment and webview characteristic-based medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101382958A (en) * | 2008-10-21 | 2009-03-11 | 深圳华为通信技术有限公司 | Web page loading method and device |
CN102098330A (en) * | 2010-12-29 | 2011-06-15 | 东莞宇龙通信科技有限公司 | Method, device and system for asynchronous transmission based on json data format |
US20130174183A1 (en) * | 2000-02-04 | 2013-07-04 | Robert Kieffer | Optimized Delivery of Web Application Code |
CN103218434A (en) * | 2013-04-15 | 2013-07-24 | 北京小米科技有限责任公司 | Method and device for loading static resource |
CN104063431A (en) * | 2014-06-10 | 2014-09-24 | 百度在线网络技术(北京)有限公司 | Method and equipment for processing static resources |
CN104133685A (en) * | 2014-08-05 | 2014-11-05 | 广州唯品会网络技术有限公司 | Method and system for front-end development of website |
CN104601691A (en) * | 2015-01-13 | 2015-05-06 | 北京中交兴路车联网科技有限公司 | Method and system for increasing loading speed of Web site resource |
-
2015
- 2015-06-08 CN CN201510309048.5A patent/CN106293675B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130174183A1 (en) * | 2000-02-04 | 2013-07-04 | Robert Kieffer | Optimized Delivery of Web Application Code |
CN101382958A (en) * | 2008-10-21 | 2009-03-11 | 深圳华为通信技术有限公司 | Web page loading method and device |
CN102098330A (en) * | 2010-12-29 | 2011-06-15 | 东莞宇龙通信科技有限公司 | Method, device and system for asynchronous transmission based on json data format |
CN103218434A (en) * | 2013-04-15 | 2013-07-24 | 北京小米科技有限责任公司 | Method and device for loading static resource |
CN104063431A (en) * | 2014-06-10 | 2014-09-24 | 百度在线网络技术(北京)有限公司 | Method and equipment for processing static resources |
CN104133685A (en) * | 2014-08-05 | 2014-11-05 | 广州唯品会网络技术有限公司 | Method and system for front-end development of website |
CN104601691A (en) * | 2015-01-13 | 2015-05-06 | 北京中交兴路车联网科技有限公司 | Method and system for increasing loading speed of Web site resource |
Cited By (17)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN108287704A (en) * | 2017-01-10 | 2018-07-17 | 北大方正集团有限公司 | The method and system that web front-end exploration project is built |
CN106933965A (en) * | 2017-02-08 | 2017-07-07 | 福建省华渔教育科技有限公司 | The method of static resource request |
CN107169000A (en) * | 2017-03-31 | 2017-09-15 | 武汉斗鱼网络科技有限公司 | Static resource dissemination method and device |
CN107169000B (en) * | 2017-03-31 | 2018-08-10 | 武汉斗鱼网络科技有限公司 | Static resource dissemination method and device |
CN107370791A (en) * | 2017-06-23 | 2017-11-21 | 微梦创科网络科技(中国)有限公司 | The method and system of filename in automatic synchronization renewal content distributing network |
CN107341038A (en) * | 2017-07-26 | 2017-11-10 | 成都三零盛安信息***有限公司 | Compatible processing method, device and electronic equipment |
CN107341038B (en) * | 2017-07-26 | 2020-11-03 | 成都三零盛安信息***有限公司 | Compatibility processing method and device and electronic equipment |
CN107436787A (en) * | 2017-07-31 | 2017-12-05 | 腾讯科技(深圳)有限公司 | Method for processing resource, device, storage medium and electronic installation |
CN107748689A (en) * | 2017-10-19 | 2018-03-02 | 阿里巴巴集团控股有限公司 | A kind of web page display method and apparatus |
CN110244975A (en) * | 2018-03-08 | 2019-09-17 | 北京京东尚科信息技术有限公司 | A kind of generation method and device of static resource version number |
CN108416029A (en) * | 2018-03-09 | 2018-08-17 | 深圳市富途网络科技有限公司 | A kind of static resource update method and system |
CN110196724A (en) * | 2018-08-17 | 2019-09-03 | 平安科技(深圳)有限公司 | File loading method, terminal, server, computer equipment and storage medium |
CN110109664A (en) * | 2018-10-18 | 2019-08-09 | 神思旭辉医疗信息技术有限责任公司 | A kind of integrated system and method for the page |
CN109634654A (en) * | 2018-12-04 | 2019-04-16 | 北京马上慧科技术有限公司 | A kind of page packaging method, device, system, computer equipment and storage medium |
CN109885791A (en) * | 2019-01-03 | 2019-06-14 | 深圳壹账通智能科技有限公司 | A kind of front end page access method, device and electronic equipment |
CN113515328A (en) * | 2020-04-09 | 2021-10-19 | 北京沃东天骏信息技术有限公司 | Page rendering method and device, electronic equipment and storage medium |
CN118069950A (en) * | 2024-04-24 | 2024-05-24 | 安徽省交通规划设计研究总院股份有限公司 | Webview characteristic-based method, webview characteristic-based device, webview characteristic-based equipment and webview characteristic-based medium |
Also Published As
Publication number | Publication date |
---|---|
CN106293675B (en) | 2020-12-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106293675A (en) | Static system resource loading method and device | |
CN101127655B (en) | Method and system for integrating existing www systems | |
CN100353733C (en) | RSS message interactive processing method based on XML file | |
US20210216288A1 (en) | Api-based software development platform | |
US20110314091A1 (en) | Method and system for automated analysis and transformation of web pages | |
CN108572819A (en) | Method for updating pages, device, terminal and computer readable storage medium | |
CN101382893B (en) | On-line assembling method for component based on Web service | |
CN103309884A (en) | User behavior data collecting method and system | |
CN103389895A (en) | Method and system for generating front end page | |
CN103440151A (en) | Method and apparatus for dynamically loading Web page | |
CN102812456A (en) | Method For Content Folding | |
CN110286917A (en) | File packing method, device, equipment and storage medium | |
CN100596139C (en) | System and method for building component applications using metadata defined mapping between message and data domains | |
CN101819584B (en) | Light weight intelligent webpage content analysis method | |
CN106294885A (en) | A kind of data collection towards isomery webpage and mask method | |
CN105068802A (en) | Cross device running Web application software implementation system and method | |
CN102253986A (en) | Method and device for improving webpage displaying effect in multiple terminals | |
CN101807204A (en) | Dynamic creation method of processing Web service with remote sensing image | |
KR20120122959A (en) | Method and Device for Collecting Web Contents and Computer-readable Recording Medium for the same | |
CN102955852A (en) | Method, device and equipment for webpage resource processing | |
Dotti et al. | Specification of mobile code systems using graph grammars | |
CN108845864B (en) | Spring frame-based JVM garbage recycling method and device | |
CN101458693A (en) | Web page download parsing system and method | |
CN101876998A (en) | Method and system for editing data | |
CN107408055A (en) | code cache system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |