@@ -30,7 +30,7 @@ export default async function nuxtRedisCache(moduleOptions) {
3030 const isCacheCleanEndpointEnabled = options . cacheCleanEndpoint && options . cacheCleanEndpoint . enabled !== false
3131
3232 if ( isCacheCleanEndpointEnabled ) {
33- this . addServerMiddleware ( ssrRedisCacheMiddleware ( client , options . cacheCleanEndpoint ) )
33+ this . addServerMiddleware ( { path : options . cacheCleanEndpoint . path || '/ssr-redis-cache' , handler : ssrRedisCacheMiddleware ( client , options . cacheCleanEndpoint ) } )
3434 }
3535
3636 console . log ( '[Nuxt SSR Redis Cache]:' , 'Cache clean endpoint is ' + ( isCacheCleanEndpointEnabled ? 'enabled\x1b[32m ✔' : 'disabled\x1b[31m ✘' ) + '\n' )
@@ -41,7 +41,7 @@ export default async function nuxtRedisCache(moduleOptions) {
4141
4242 renderer . renderRoute = async function ( route , context ) {
4343 // Check if the route is cacheable, if not, just render the route (cache-control: no-cache is set when the browser cache is disabled)
44- if ( ! isCacheable ( route , options . matches , context . req . headers [ 'cache-control' ] ) ) {
44+ if ( ! isCacheable ( route , options . paths , context . req . headers [ 'cache-control' ] ) ) {
4545 return renderRoute ( route , context )
4646 }
4747
@@ -72,9 +72,9 @@ export default async function nuxtRedisCache(moduleOptions) {
7272 context . res . setHeader ( 'X-Cache' , hitCache ? 'HIT' : 'MISS' )
7373 }
7474
75- if ( ! hitCache && isCacheable ( url , options . matches ) ) {
75+ if ( ! hitCache && isCacheable ( url , options . paths ) ) {
7676 client . set ( 'nuxt/route::' + url , serialize ( result ) , {
77- EX : options . expireTime ,
77+ EX : options . ttl ,
7878 } )
7979 }
8080 } )
@@ -90,8 +90,8 @@ function buildOptions(moduleOptions) {
9090 } ,
9191 password : null ,
9292 } ,
93- expireTime : 60 * 60 ,
94- matches : [ ] ,
93+ ttl : 60 * 60 ,
94+ paths : [ ] ,
9595 cacheCleanEndpoint : {
9696 enabled : false ,
9797 path : '/ssr-redis-cache' ,
@@ -102,8 +102,8 @@ function buildOptions(moduleOptions) {
102102 return Object . assign ( { } , defaultOptions , moduleOptions )
103103}
104104
105- function isCacheable ( url , matches = [ ] , cacheControl = null ) {
106- return cacheControl !== 'no-cache' && matches . some ( ( path ) => ( path instanceof RegExp ? path . test ( url ) : url . startsWith ( path ) ) )
105+ function isCacheable ( url , paths = [ ] , cacheControl = null ) {
106+ return cacheControl !== 'no-cache' && paths . some ( ( path ) => ( path instanceof RegExp ? path . test ( url ) : url . startsWith ( path ) ) )
107107}
108108
109109module . exports . meta = require ( '../package.json' )
0 commit comments