Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Website Template] Updating a post won't revalidate the Archive Block data #10750

Open
concreo opened this issue Jan 23, 2025 · 1 comment
Open
Labels
status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@concreo
Copy link

concreo commented Jan 23, 2025

Describe the Bug

To prevent caching issues, it's crucial to note that updating or creating a new post does not automatically refresh pages displaying the Archive Block. This could lead to outdated information being presented to users.

Link to the code that reproduces this issue

https://github.com/payloadcms/payload/tree/main/templates/website

Reproduction Steps

Use the basic website template.

  1. Create a post
  2. Add the Archive Block to your home page
  3. Build your website
  4. Update the post OR create a new one
  5. The Archive Block on the home page is outdated

Which area(s) are affected? (Select all that apply)

area: templates

Environment Info

# Database connection string
DATABASE_URI=mongodb://127.0.0.1/your-database-name

# Or use a PG connection string
#DATABASE_URI=postgresql://127.0.0.1:5432/your-database-name

# Used to encrypt JWT tokens
PAYLOAD_SECRET=YOUR_SECRET_HERE

# Used to configure CORS, format links and more. No trailing slash
NEXT_PUBLIC_SERVER_URL=http://localhost:3000

# Secret used to authenticate cron jobs
CRON_SECRET=YOUR_CRON_SECRET_HERE
@concreo concreo added status: needs-triage Possible bug which hasn't been reproduced yet validate-reproduction labels Jan 23, 2025
@schlesingermatthias
Copy link

schlesingermatthias commented Jan 26, 2025

Can confirm the issue. I could modify revalidatePost to revalidate the pages that use posts as well, but that doesn't really scale if blocks are moved to different pages etc.

export const revalidatePost: CollectionAfterChangeHook<Post> = ({
  doc,
  previousDoc,
  req: { payload },
}) => {
  revalidatePath("/posts")
  revalidatePath("/author/[slug]/posts", "page")
  if (doc._status === 'published') {
    const path = `/posts/${doc.slug}`

    payload.logger.info(`Revalidating post at path: ${path}`)

    revalidatePath(path)
  }
  ...

what would be an official solution to achieve revalidation of pages that use certain collections?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

2 participants