4

I am using MongoDB as my database for NodeJS system what working heavily with it database.

I am using Mongoose module as database controller.

My question is: Is MongoDB or Mongoose somehow caching queries? I am experiencing problems with fetching data from database.

What I mean by that?

When I for for example use aggregate db query in same second and I expect different results, I am getting same result.

It can be caused by my code, but before I start digging into I need to be sure that its not caused by some hidden cashing feature.

4

The FAQ: MongoDB Fundamentals says this:

Does MongoDB handle caching?

Yes. MongoDB keeps most recently used data in RAM. If you have created indexes for your queries and your working data set fits in RAM, MongoDB serves all queries from memory.

MongoDB does not cache the query results in order to return the cached results for identical queries.

However, this does not mean that caching does not occur at all: If you are reaching the MongoDB server via the Web, both the browser and the web-server are perfectly capable of caching URLs and their answer.

In most cases, good web-servers do not cache a URL that looks to be dynamic, meaning that it includes a question-mark (?) with parameter(s) at its end. You may check the documentation of your web-server, or send a query to its developers (if accessible), to know if this remedy will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.