Skip to content

Caching raw page HTML in Redis #65522

Answered by SouthLink
lsliwaradioluz asked this question in Help
Discussion options

You must be logged in to vote

In versions of next.js 13.4 and below, redis caching can be implemented with the following code:

const next = require("next");
const app = next({ dev, hostname, port });
const Koa = require("koa");
const Router = require("koa-router");
const RedisClient = require("redis");
const RedisClustr = require("redis-clustr");

app
  .prepare()
  .then(() => {
    return new Promise((resolve, reject) => {
      let client;

      // init redis
      client = new RedisClustr({
        //...
      });

    });
  })
  .then((RedisClient) => {
    const server = new Koa();
    const router = new Router();

    if (RedisClient) {
      const ssrCacheInstance = new RedisCache(RedisClient);

      router.…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by lsliwaradioluz
Comment options

You must be logged in to vote
2 replies
@SouthLink
Comment options

@lsliwaradioluz
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants