Next.js Discord

Discord Forum

Custom redis cache handler returns JS files with HTML in them

Unanswered
Sphecid wasp posted this in #help-forum
Open in Discord
Sphecid waspOP
We are self hosting our NextJS app in Azure, containerized in an App Service.
We also have a Redis instance in Azure and we want to use that as the page data cache since we have the need to be able to scale out our application on multiple pods.

So, in next.config.js I have this:

cacheHandler: !isDev && USE_REDIS_CACHE ? require.resolve('./cache-handler.js') : undefined,

I use this as the cache handler: https://dev.to/rafalsz/scaling-nextjs-with-redis-cache-handler-55lh

I get really inconsistent results with this. Sometimes the site spins up after deploy and kind of works the way it should. Keys are set in redis and everything looks good. Next deploy all or some of the JS files breaks and only returns HTML. This does not happen if I remove the custom cache handler in next.config.js. See attached file.

Ive been pulling my hair for over two weeks over this and trying numerous things but I cant get it to work. Any help GREATLY appreciated!

0 Replies