mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
added ability to disable browser cache from config.json
This commit is contained in:
parent
d9bd65d9a2
commit
cc3a773d5d
5 changed files with 25 additions and 20 deletions
|
|
@ -169,6 +169,8 @@ for now it's much simplier.
|
|||
* Added ability to change configs without restart
|
||||
(works for js minification only).
|
||||
|
||||
* Added ability to disable browser cache from config.json.
|
||||
|
||||
|
||||
2012.12.12, Version 0.1.8
|
||||
|
||||
|
|
|
|||
|
|
@ -197,8 +197,12 @@
|
|||
if(!Config.minification)
|
||||
main.config = Config = lReadedConf;
|
||||
|
||||
console.log(Config);
|
||||
|
||||
Util.tryCatchLog(function(){
|
||||
Config.minification.js = lReadedConf.minification.js;
|
||||
Config.minification.js = lReadedConf.minification.js;
|
||||
Config.cache = lReadedConf.cache;
|
||||
|
||||
Minify.setAllowed(Config.minification);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
"html" : true,
|
||||
"img" : true
|
||||
},
|
||||
"cache" : false,
|
||||
"logs" : false,
|
||||
"show_keys_panel" : true,
|
||||
"server" : true,
|
||||
|
|
|
|||
|
|
@ -12,7 +12,13 @@
|
|||
ext,
|
||||
path, fs, zlib, url,
|
||||
|
||||
OK, FILE_NOT_FOUND;
|
||||
OK, FILE_NOT_FOUND,
|
||||
|
||||
Config = {
|
||||
server : true,
|
||||
socket : true,
|
||||
port : 80
|
||||
};
|
||||
|
||||
/* Consts */
|
||||
|
||||
|
|
@ -67,11 +73,7 @@
|
|||
exports.ext = ext = jsonrequire('ext');
|
||||
exports.mainpackage = rootrequire('package');
|
||||
/* base configuration */
|
||||
exports.config = {
|
||||
server : true,
|
||||
socket : true,
|
||||
port : 80
|
||||
},
|
||||
exports.config = Config,
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -155,22 +157,17 @@
|
|||
* name - имя файла
|
||||
* gzip - данные сжаты gzip'ом
|
||||
* query
|
||||
* cacheControl
|
||||
* https://developers.google.com/speed/docs/best-practices/caching?hl=ru#LeverageProxyCaching
|
||||
*/
|
||||
function generateHeaders(pParams){
|
||||
var lRet = Util.checkObjTrue(pParams, 'name'),
|
||||
var lRet = Util.checkObjTrue(pParams, ['name']),
|
||||
p = pParams;
|
||||
Util.log(pParams);
|
||||
Util.log(lRet);
|
||||
|
||||
if(lRet){
|
||||
var lExt = Util.getExtension(p.name),
|
||||
lType = ext[lExt] || 'text/plain',
|
||||
lContentEncoding = '';
|
||||
|
||||
if( !Util.checkObjTrue(pParams, 'cacheControl') )
|
||||
p.cacheControl = 1;
|
||||
|
||||
/* if type of file any, but img - then we shoud specify charset */
|
||||
if( !Util.isContainStr(lType, 'img') )
|
||||
lContentEncoding = '; charset=UTF-8';
|
||||
|
|
@ -179,20 +176,21 @@
|
|||
lType = 'application/octet-stream';
|
||||
|
||||
|
||||
if( !Util.strCmp(lExt, '.appcache') )
|
||||
p.cacheControl = 31337 * 21;
|
||||
|
||||
lRet = {
|
||||
'Content-Type': lType + lContentEncoding,
|
||||
'last-modified': new Date().toString(),
|
||||
'Vary': 'Accept-Encoding'
|
||||
};
|
||||
|
||||
if(p.cacheControl)
|
||||
lRet['cache-control'] = 'max-age=' + p.cacheControl;
|
||||
if( !Util.strCmp(lExt, '.appcache') && exports.config.cache){
|
||||
var lCacheControl = 31337 * 21;
|
||||
lRet['cache-control'] = 'max-age=' + lCacheControl;
|
||||
}
|
||||
|
||||
if(p.gzip)
|
||||
lRet['content-encoding'] = 'gzip';
|
||||
|
||||
Util.log(Config);
|
||||
}
|
||||
|
||||
return lRet;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/*
|
||||
/*
|
||||
* Licensed under MIT License http://www.opensource.org/licenses/mit-license
|
||||
* Module contain additional system functional
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue