Merged in fix/resolve-entry-clearing-cache (pull request #2445)
fix: use shared cache key when revalidating urls * fix: use shared cache key when revalidating urls Approved-by: Linus Flood
This commit is contained in:
@@ -12,6 +12,7 @@ import { languageSwitcherAffix } from "@/server/routers/contentstack/languageSwi
|
||||
import { affix as metadataAffix } from "@/server/routers/contentstack/metadata/utils"
|
||||
import { affix as pageSettingsAffix } from "@/server/routers/contentstack/pageSettings/utils"
|
||||
|
||||
import { resolveEntryCacheKey } from "@/utils/entry"
|
||||
import {
|
||||
generateRefsResponseTag,
|
||||
generateRefTag,
|
||||
@@ -121,8 +122,10 @@ export async function POST(request: NextRequest) {
|
||||
await cacheClient.deleteKey(contentEntryTag, { fuzzy: true })
|
||||
|
||||
if (entry.url) {
|
||||
console.info(`Revalidating url: ${entry.url}`)
|
||||
await cacheClient.deleteKey(entry.url, { fuzzy: true })
|
||||
const resolveEntryTag = resolveEntryCacheKey(entryLocale, entry.url)
|
||||
console.info(`Revalidating url: ${resolveEntryTag}`)
|
||||
|
||||
await cacheClient.deleteKey(resolveEntryTag, { fuzzy: true })
|
||||
}
|
||||
|
||||
if (entry.breadcrumbs) {
|
||||
|
||||
@@ -9,12 +9,16 @@ import { internalServerError } from "@/server/errors/next"
|
||||
|
||||
import { validateEntryResolveSchema } from "@/types/requests/entry"
|
||||
|
||||
export function resolveEntryCacheKey(lang: Lang, url: string) {
|
||||
return `${lang}:${url}:resolveentry`
|
||||
}
|
||||
export async function resolve(url: string, lang = Lang.en) {
|
||||
const variables = { locale: lang, url: url || "/" }
|
||||
|
||||
const cacheKey = resolveEntryCacheKey(variables.locale, variables.url)
|
||||
|
||||
// The maximum amount of content types you can query is 6, therefor more
|
||||
// than that is being batched
|
||||
const cacheKey = `${lang}:${url}:resolveentry`
|
||||
const response = await batchRequest([
|
||||
{
|
||||
document: EntryByUrlBatch1,
|
||||
|
||||
Reference in New Issue
Block a user