Ethers.js – Disabling Cache to Ensure Fresh Data

ethers.js

I want to disable cache when suing ethersjs v6. Did not find any documentation related to that. Is that possible?

Best Answer

In the provider options, you can pass a negative cacheTimeout which would disable caching (source).

const provider = new ethers.JsonRpcProvider(
  "https://rpc.url",
  undefined,
  {
    cacheTimeout: -1,
  }
);
Related Topic