From 58f4fff45f681a9f26c058fbc70cb31a30892adf Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Fri, 17 Dec 2021 21:14:26 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E7=8E=AF=E5=A2=83=E6=89=93?= =?UTF-8?q?=E5=8C=85=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/cache/cache_manager.js | 2 +- lib/cache/memory_cache.js | 2 +- pages/article/[slug].js | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/cache/cache_manager.js b/lib/cache/cache_manager.js index 84ac9519..24bf33ae 100644 --- a/lib/cache/cache_manager.js +++ b/lib/cache/cache_manager.js @@ -1,6 +1,6 @@ import BLOG from '@/blog.config' import { getCacheFromMemory, setCacheToMemory } from '@/lib/cache/memory_cache' -const enableCache = true && !BLOG.isProd // 生产环境禁用 +const enableCache = true // 生产环境禁用 /** * 为减少频繁接口请求,notion数据将被缓存 diff --git a/lib/cache/memory_cache.js b/lib/cache/memory_cache.js index d047b838..ce107e0c 100644 --- a/lib/cache/memory_cache.js +++ b/lib/cache/memory_cache.js @@ -5,5 +5,5 @@ export async function getCacheFromMemory (key, options) { } export async function setCacheToMemory (key, data) { - await cache.put(key, data, 30 * 60 * 1000) // 30 minutes + await cache.put(key, data, 60 * 1000) // 1 minutes } diff --git a/pages/article/[slug].js b/pages/article/[slug].js index 4686a74b..baff300c 100644 --- a/pages/article/[slug].js +++ b/pages/article/[slug].js @@ -31,7 +31,9 @@ const Slug = ({ post, blockMap, tags, prev, next, allPosts, recommendPosts, cate export async function getStaticPaths () { let posts = [] - posts = await getAllPosts({ from: 'slug - paths', includePage: true }) + if (BLOG.isProd) { + posts = await getAllPosts({ from: 'slug - paths', includePage: true }) + } return { paths: posts.map(row => `${BLOG.path}/article/${row.slug}`), fallback: true