-
Notifications
You must be signed in to change notification settings - Fork 18
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
Unpublished document webhook trigger does not invalidate cache #94
Comments
Unfortunately it is not possible to query unpublished documents; https://community.prismic.io/t/query-unpublished-draft-archive-documents/6537/7 |
Three ways to circumvent this from most desirable to least desirable;
|
Actually, solution 1 would only work for Prismic custom types that are standalone pages like Blog, Landing Page, News, Agenda, etc. This won't work for Prismic custom types that are used as "blocks" like USP's or Footers because those might show up on every page. So for best results, we need a hybrid approach between solution 1 and solution 2. |
Since Magento cache tags are the responsibility of the blocks in a certain page, the way for us to handle this is to add tags to a block that is being included when a page is rendered using Prismic data. That means adding it to We could abuse one of the existing blocks but I'd vote in favor of creating a new block just to handle the cache tags, which doesn't output anything. The block should have a
For this, we probably need to store This way we can flush specific cache entries by using specific or more generic cache tags;
|
@JeroenBoersma thoughts on this? |
Wait, maybe we can retrieve the document ID and add cache tags on the extension's AbstractBlock? That way, every page that includes any of the Prismic blocks can get the cache tags and can be flushed using just the documentId so we won't need a hybrid approach. |
In a nextjs project which also uses prismic I stumbled across a very similar problem. This project uses webhooks from prismic to revalidate static content from next. However when Prismic only sends the document id, there is no way to figure out which url this document corresponds to and rebuild content in next. Eventually I figured out a way of working around this was to always revalidate the Prismic data at least once every day or so, using nextjs default Incremental Static Regeneration method. Unfortunately this means the website does not update on-demand. |
Both webhook controllers now use the document ID in the payload to retrieve documents through the API and consequently flush the relevant cache types.
This works perfectly fine on publish. However, on Unpublish, the document is not retrievable through the API anymore. So we don't have data on what custom type it is and we can't flush the cache.
So triggering a webhook on an Unpublish trigger doesn't invalidate anything right now.
The text was updated successfully, but these errors were encountered: