How to invalidate cache / reduce cache time (@amityco/js-sdk 5.21.0)

I’m trying to query posts once a user has followed/unfollowed someone to get their latest feed. It looks like amity is caching the response and returning an old one, as the response doesn’t update until I refresh after a while. In the docs, I notied a modelDataLifespan variable, but I am unsure as to how to set the config in my project.

Also, is there any way to directly invalidate the cache on a request? Thanks in advance for your help

Hi @evanABC so you did call query post after follow/unfollow successfully? but still the feed is returning the old feed?

That’s right - and from the docs I think it’s a caching issue

follow: async userId => {
  await followUser(userId);
  handles.queryUserFeed();
},

Since I’m using an async call to follow/unfollow, I’m pretty confident on is happening after ther other

1 Like

Hey, still having a problem here - it’s causing pretty big issues.

The request to get all posts for a user’s feed isn’t changing, even after an unfollow/follow/post creation

Hi @evanABC I have passed this to our engineering team to check, I will keep you posted on the progress :)) :pray:

1 Like

Hi, any update on this?

Evan

Hello @evanABC Sorry for late response. After checking with the team, unfortunately, this is by design for JS SDK. Would you consider switching to TS SDK instead? You will be able to disable or reduce caching time on TS SDK.