diff --git a/ChangeLog b/ChangeLog index 2c45d9f8..ec9de7ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/cloudcmd.js b/cloudcmd.js index 13dd67ff..069d4b11 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -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); }); } diff --git a/json/config.json b/json/config.json index 4a411e71..18d891b7 100644 --- a/json/config.json +++ b/json/config.json @@ -7,6 +7,7 @@ "html" : true, "img" : true }, + "cache" : false, "logs" : false, "show_keys_panel" : true, "server" : true, diff --git a/lib/server/main.js b/lib/server/main.js index b0304179..2668c8d1 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -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; diff --git a/lib/util.js b/lib/util.js index 683bcc28..77c3463b 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,4 +1,4 @@ -/* +/* * Licensed under MIT License http://www.opensource.org/licenses/mit-license * Module contain additional system functional */