question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Integration with ssr-caching

See original GitHub issue

Next.js provides a great SSR caching example which makes use of Next.js’ renderToHTML and renderError. Can next-routes somehow be used in conjunction with this or could this be implemented?

https://github.com/zeit/next.js/tree/master/examples/ssr-caching

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
fridayscommented, Feb 13, 2017

I didn’t try it yet, but it should work like this with the caching example:

const express = require('express')
const next = require('next')
const routes = require('./routes')
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dir: '.', dev })
const handle = app.getRequestHandler()
const LRUCache = require('lru-cache')

const ssrCache = new LRUCache({
  max: 100,
  maxAge: 1000 * 60 * 60 // 1hour
})

app.prepare().then(() => {
  express().use(renderAndCache).listen(3000)
})

function renderAndCache (req, res) {
  if (ssrCache.has(req.url)) {
    return res.send(ssrCache.get(req.url))
  }

  // Match route + parse params
  const {route, params} = routes.match(req.url)
  if (!route) return handle(req, res)

  app.renderToHTML(req, res, route.page, params).then((html) => {
    ssrCache.set(req.url, html)
    res.send(html)
  })
  .catch((err) => {
    app.renderError(err, req, res, route.page, params)
  })
}
0reactions
seduboiscommented, Feb 15, 2017

It doesn’t since the catchall update from the last version, can you check?

@fridays created https://github.com/fridays/next-routes/issues/6

Also you can now use routes.isNextPath(req.url)

Seems to work 👍 (https://github.com/relatenow/relate/commit/f8032ba752d8d45d7d5ceebc8412b8118614f465#diff-bba6db1dd9623c6662b43cc660a5975cR20)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Caching Reports (SSRS) - SQL - Microsoft Learn
Caching is a performance-enhancement technique. The contents of the cache are volatile and can change as reports are added, replaced, or removed ...
Read more >
How To Enable Caching in SQL Server Reporting Services
SSRS has a built-in caching capability where the data required to render a report can be retrieved from the ReportServerTempDB database instead ...
Read more >
SSRS Tip: Adding A Tool to Clear the SSRS Data Cache
This occurs because SSRS automatically caches the data for the most recent run of the report. SSRS will use the cached data until...
Read more >
SSRS and report caching, dynamic refresh for Data Warehouses
– The @CacheReport – is used to flag whether the report is cached or not. – The @ExpirationFlags – is the option which...
Read more >
Preventing Data Caching when Developing SSRS Reports
The Problem: Data is Cached · Solution 1 - Just Refresh the Screen · Solution 2 - Delete the Cached Data · Solution...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found