UNPKG

superapi-cache

Version:
35 lines (27 loc) 649 B
export default function exclude (req, service, exclusions = {}) { if (service) { if (service.use && service.use.cache === false) { return true } } if ((typeof exclusions.filter === 'function') && !exclusions.filter(req)) { return true } // do not cache request with query if (exclusions.query && req.url.match(/\?.*$/)) { return true } let found = false const paths = exclusions.paths || [] paths.forEach(regexp => { if (req.url.match(regexp)) { found = true return found } }) if (found) { return true } // All rules explained. fo not rewrite regexp. return false }