Hi
@805318668556435486
Please don't cross-post questions between channels
Have a look here at how Payload uses hooks to achieve revalidation:
https://github.com/payloadcms/payload/blob/main/templates/website/src/collections/Pages/hooks/revalidatePage.tsThis is how the website template actually handles "Pages" collection pages:
https://github.com/payloadcms/payload/blob/main/templates/website/src/app/(frontend)/%5Bslug%5D/page.tsxHi, noted on the cross-posting, won’t happen again,
No worries!
Hey
@654031862146007055, I have a quick question, would you mind helping me out?
I'm a bit confused about the behavior of the payload.
like here this collection is default from payload initialization:
import type { CollectionConfig } from 'payload'
export const Media: CollectionConfig = {
slug: 'media',
access: {
read: () => true,
},
fields: [
{
name: 'alt',
type: 'text',
required: true,
},
],
upload: true,
}when i upload and delete anything in this collection then its revalidate auto then why i need to add manual revalidation for my categories collection ?
.
I have no idea what you mean by revalidate "auto" - when you create a new Media, it has a distinct new ID and a url to reach the resource. There's not really any revalidation. If you wanted to udpate the Media on pages that are using ISR, you would need to trigger a revalidation of those pages, which is what those hooks are for.
You create a page, it gets "cached" on the server and sent out to clients. Then you want to make an update, but you need to let your server/frontend know that the cache has been invalidated, this is the purpose of those hooks essentially.
What’s confusing me is that in my case, I haven’t added any custom revalidation hooks for the Media collection, yet when I upload or delete a media item, the frontend seems to reflect those changes right away.
On the other hand, for collections like Categories, I have to manually trigger revalidation using hooks to see updates on the frontend.
Is there a reason for this difference in behavior? Does Payload treat the Media collection differently under the hood, or am I missing something?
Sorry if my question sounds a bit off, Im still pretty new to how Payload and ISR work together, so I’m trying to wrap my head around everything.
Well, your frontend isn't showing your media collection, it's showing the page where there is a reference to that media collection document
As for your category, you're probably using calls to that category collection directly
Are you using a template?
No, I'm not using templates, I've initialized the payload in my existing app.
Thanks for you help now i got it
Star
Discord
online
Get dedicated engineering support directly from the Payload team.