Skip to content

Commit

Permalink
feat(cache): add support for path exclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanebachelier committed Feb 22, 2016
1 parent f7f4d58 commit bafe512
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function cache (config = {}) {
config.readCache = config.readCache || readCache
config.serialize = config.serialize || serialize

config.exclude = config.exclude || []

if (config.log !== false) {
config.log = typeof config.log === 'function' ? config.log : console.log.bind(console)
}
Expand All @@ -34,6 +36,19 @@ function cache (config = {}) {
return null
}

let found = false

config.exclude.forEach(regexp => {
if (req.url.match(regexp)) {
found = true
return false
}
})

if (found) {
return null
}

const uuid = key(req)

// clear cache if method different from GET
Expand Down

0 comments on commit bafe512

Please sign in to comment.