-
-
Notifications
You must be signed in to change notification settings - Fork 192
Open
Description
I have the following:
const client = redis.createClient({ url: 'redis url...' });
const cacheWithRedis = apicache.options({
debug: true,
redisClient: client,
}).middleware;
app.get('*',
cacheWithRedis('1 day', () => true),
(req, res) => {
console.log('post cache, rendering html');
res.render(someHtmlFile);
}
When I run consecutive requests against the server for the same url I always get duplicates of the add to cache logs, but the cached result is never returned.
[apicache] adding cache entry for "/my-url" @ 1 day - 1.92sec
[apicache] _apicache.headers:
[apicache] res.getHeaders(): [Object: null prototype] {
'x-powered-by': 'Express',
'content-type': 'text/html; charset=utf-8',
'content-length': '293611',
etag: 'W/"47aeb-2ew9IPOkaA3owFUD/RU5VqJ4Vrk"'
}
[apicache] cacheObject: {
status: 200,
headers: {
'x-powered-by': 'Express',
'content-type': 'text/html; charset=utf-8',
'content-length': '293611',
etag: 'W/"47aeb-2ew9IPOkaA3owFUD/RU5VqJ4Vrk"'
},
data: <Buffer 3c 21 44 4f 43 54 59 50 45 20 68 74 6d 6c 3e 3c 68 74 6d 6c 20 6c 61 6e 67 3d 22 65 6e 22 3e 3c 68 65 61 64 3e 3c 6c 69 6e 6b 20 72 65 6c 3d 22 70 72 ... 293[apicache] res.getHeaders(): [Object: null prototype] {
}
[apicache] adding cache entry for "/my-url" @ 1 day - 2.75sec
[apicache] _apicache.headers:
[apicache] res.getHeaders(): [Object: null prototype] {
'x-powered-by': 'Express',
'content-type': 'text/html; charset=utf-8',
'content-length': '293611',
etag: 'W/"47aeb-2ew9IPOkaA3owFUD/RU5VqJ4Vrk"'
}
[apicache] cacheObject: {
status: 200,
headers: {
'x-powered-by': 'Express',
'content-type': 'text/html; charset=utf-8',
'content-length': '293611',
etag: 'W/"47aeb-2ew9IPOkaA3owFUD/RU5VqJ4Vrk"'
},
data: <Buffer 3c 21 44 4f 43 54 59 50 45 20 68 74 6d 6c 3e 3c 68 74 6d 6c 20 6c 61 6e 67 3d 22 65 6e 22 3e 3c 68 65 61 64 3e 3c 6c 69 6e 6b 20 72 65 6c 3d 22 70 72 ... 293561 more bytes>,
encoding: undefined,
timestamp: 1649866135.151
}
...etc
I have the cache middleware second function return true all the time, but it always goes to the next middleware which actually renders the html on the server and sends it back. Am I missing anything?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels