Skip to content

clearDataCache

Empties the data cache that every chart shares, so the next load of each URL fetches it again. Call it when the data behind your URLs changes for the whole page, such as after a user logs out.

Every chart that caches (the cache config key, on by default) keeps the files it fetches in one shared cache, so the first load below fetches fruits.csv and any later one reads it from the cache. After clearDataCache(), the next load fetches the file again. Requests already in flight still reach the charts waiting on them, but their responses are not cached.

import {clearDataCache, load} from "@d3plus/data";

const chart = {schema: {cache: true}, config() {}};
const fruits = () =>
  new Promise(resolve =>
    load.call(chart, "/data/fruits.csv", undefined, "data", (error, rows) =>
      resolve(rows.length),
    ),
  );

fruits();
clearDataCache();
fruits();

Parameters

import {clearDataCache} from "@d3plus/data";

Takes no parameters.