MongoDB Atlas free tier (M0) caching queries for far too long

I have a collection for users which embeds a subdocument called avatar, and I have a collection of recipes with an ‘author’ field which links to a user. I can reproduce this issue reliably by doing the following:

  1. Update the avatar for a user.
  2. Query the author of a recipe for which the above user is the author.
  3. Get the avatar of the queried author.
  4. It will still be the old avatar.

Sometimes the author does not update for over a day but I can check in the collection via MongoDB Atlas portal and see that the user has the new avatar.

That seems to indicate that it is in your code…

Not a code issue. Eventually the cache will update without touching any code.
I’ve actually been able to reproduce with a fresh, very barebones express server that doesn’t have any API code.

Hi @Max_Randle, welcome to the forums!

Atlas does not cache queries, so this behaviour is unexpected. Please provide some more information to help investigate this issue:

  1. The MongoDB driver version you are using
  2. The method in which you are querying the Atlas cluster (e.g. directly, API, GraphQL, etc)
  3. How you are verifying that the avatar has not changed (e.g. Are you checking the result document? Is there a UI change that occurs using an avatar url?)

Regards,
Jason

1 Like