nextjs Use memory-cache Plug in to achieve server side caching
import cacheData from 'memory-cache';
async function putCache(url, options) { // url Identify for cache
const value = cacheData.get(url); // Access to the cache
if (value) {
// If you have a cache
*codeing*
} else {
const hours = 24;
// Request interface obtain data
cacheData.put(url, data, hours * 1000 * 60 * 60); // url Identify for cache data For data The third parameter is the time in milliseconds
return data;
}
}