Closed dariye closed 7 years ago
Could you provide some more information? Example? etc.?
Hey @HaNdTriX
I have the following:
...
function renderAndCache(req, res, pagePath, queryParams) {
const key = getCacheKey(req)
if (ssrCache.has(key)) {
console.log(`CACHE HIT: ${key}`)
res.send(ssrCache.get(key))
return
}
app.renderToHTML(req, res, pagePath, queryParams)
.then((html) => {
if ( !dev ) {
console.log(`CACHE MISS: ${key}`)
ssrCache.set(key, html)
console.log(`CACHE SET: ${key}`)
}
res.send(html)
})
.catch((error) => {
app.renderError(error, req, res, pagePath, queryParams)
})
}
...
I guess the question is how do I get the requests to named routes using next-routes
and pass the right arguments to the renderAndCache
? An option is to server.get()
for all the routes but wondering if there's a cleaner way to go about it.
thanks @fridays. Will close this and look into #4
Thanks for this lib! I'm trying to implement SSR caching . Seems not to be working as expected. I'm unable to get the right page path to use the caching function.