Force cache to expire?

Hey Dato Community, my first post here :wave:

I’m testing/working on a NuxtJS SSR website/webapp where we create articles and article-comments though the CM API and publish with the CD API. However, when an article has been updated (edited or new comment) we need the cache to expire and trigger a fresh copy through CD. We can’t seem to find it in the docs … Is it possible? Or what would be the best way to deal with renewing the object cache?

1 Like

Hello @steve and welcome to Community!!! :slight_smile:

You are asking that because it’s not working automatically? Cache should expire automatically on every change. If it’s not, can you please provide an example so that we can reproduce and fix?

Thank you!

Thanks for your quick response, @mat_jack1 Good to know that it should expire on each change by default. To us it seemed that it wasn’t always the case. (Often yes, but sometimes not). But knowing this, we will dig and debug some more.

What would be the best field to check to see if it is a fresh copy, the updatedAt field or should we check for certain headers in the CD response?

all the fields should be invalidated together, so it should be the same, I think :slight_smile:

1 Like

I’m having the same issue when using the draft endpoint.

When I send a graphQL query after I update a record, it returns stale data. If I modify the text of the graphQL query, like removing a property, and send it, it returns the new, updated data.

This is a blocking issue for us, as our preview endpoints show stale data unless I update the client code to send a slightly modified query, which is untenable.

As a workaround, I’m passing the current datestamp as one of the query variables. This ensures the data is fresh.

1 Like

Hey @daniel can you reproduce the problem also in the API explorer?

If so, can you please share a screen recording so that we can try replicating ourselves? Feel free to share it here or over support, as you prefer.

Thank you!