File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ function ApiCache() {
69
69
}
70
70
} ;
71
71
72
- this . middleware = function cache ( duration ) {
72
+ this . middleware = function cache ( duration , middlewareToggle ) {
73
73
if ( typeof duration === 'string' ) {
74
74
var split = duration . match ( / ^ ( \d + ) \s ( \w + ) $ / ) ;
75
75
@@ -88,9 +88,9 @@ function ApiCache() {
88
88
return function cache ( req , res , next ) {
89
89
var cached ;
90
90
91
- if ( ! globalOptions . enabled || req . headers [ 'x-apicache-bypass' ] ) {
91
+ if ( ! globalOptions . enabled || req . headers [ 'x-apicache-bypass' ] || ( _ . isFunction ( middlewareToggle ) && ! middlewareToggle ( req , res ) ) ) {
92
92
if ( globalOptions . debug && req . headers [ 'x-apicache-bypass' ] ) {
93
- console . log ( '[api-cache]: header "x-apicache- bypass" detected, skipping cache.' ) ;
93
+ console . log ( '[api-cache]: bypass detected, skipping cache.' ) ;
94
94
}
95
95
return next ( ) ;
96
96
}
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " apicache" ,
3
- "version" : " 0.0.11 " ,
3
+ "version" : " 0.0.12 " ,
4
4
"description" : " An ultra-simplified API/JSON response caching middleware for Express/Node using plain-english durations." ,
5
5
"main" : " ./lib/apicache.js" ,
6
6
"repository" : {
You can’t perform that action at this time.
0 commit comments