Merge branch 'develop' of code-repo.d4science.org:MaDgIK/explore-services into develop
This commit is contained in:
commit
3797ddcc3a
|
@ -11,7 +11,7 @@ const properties = PropertiesReader('./properties.file');
|
||||||
const environment = properties.get("environment");
|
const environment = properties.get("environment");
|
||||||
const preloadRequests = properties.get("preloadRequests").split(',');;
|
const preloadRequests = properties.get("preloadRequests").split(',');;
|
||||||
|
|
||||||
const cacheMaxSize = 300;
|
const cacheMaxSize = 1000;
|
||||||
let cors = require('cors');
|
let cors = require('cors');
|
||||||
app.use(cors());
|
app.use(cors());
|
||||||
const lruCache = new LRUCache({ max: cacheMaxSize });
|
const lruCache = new LRUCache({ max: cacheMaxSize });
|
||||||
|
@ -57,7 +57,7 @@ let cache = () => {
|
||||||
const end = histogram.startTimer({scheme: scheme, target: target, cache: 'miss'});
|
const end = histogram.startTimer({scheme: scheme, target: target, cache: 'miss'});
|
||||||
res.sendResponse = res.send;
|
res.sendResponse = res.send;
|
||||||
res.send = (body) => {
|
res.send = (body) => {
|
||||||
if(isAllowedToBeCached(scheme, target)) {
|
if(isAllowedToBeCached(decodeURI(scheme), decodeURI(target))) {
|
||||||
let alreadyCached = lruCache.has(key);
|
let alreadyCached = lruCache.has(key);
|
||||||
entries.set(lruCache.size);
|
entries.set(lruCache.size);
|
||||||
if (!alreadyCached) {
|
if (!alreadyCached) {
|
||||||
|
@ -85,9 +85,9 @@ let cache = () => {
|
||||||
};
|
};
|
||||||
function isAllowedToBeCached(scheme, target){
|
function isAllowedToBeCached(scheme, target){
|
||||||
if(environment != "development"){
|
if(environment != "development"){
|
||||||
return scheme.indexOf("https%3A%2F%2F")!=-1 && ( target.indexOf(".openaire.eu%2F") !=-1 || target.indexOf(".zenodo.org%2Fapi%2F") !=-1 || target.indexOf("lab.idiap.ch%2Fenermaps" != -1))
|
return scheme.indexOf("https")!=-1 && ( target.indexOf(".openaire.eu/") !=-1 || target.indexOf(".zenodo.org/api/") !=-1 || target.indexOf("lab.idiap.ch/enermaps" != -1))
|
||||||
} else if(environment == "development"){
|
} else if(environment == "development"){
|
||||||
return target.indexOf(".openaire.eu%2F") !=-1 || target.indexOf(".di.uoa.gr") !=-1 || target.indexOf("dev-openaire.d4science.org") !=-1 || target.indexOf("lab.idiap.ch%2Fenermaps") != -1
|
return target.indexOf(".openaire.eu/") !=-1 || target.indexOf(".di.uoa.gr") !=-1 || target.indexOf("dev-openaire.d4science.org") !=-1 || target.indexOf("lab.idiap.ch/enermaps") != -1
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue