Skip to content

cacheKey

The key the data cache stores a fetched response under: the JSON of the URL or request object, so a request object’s fetch options are part of it. Every loader (data, links, nodes, topojson, fitObject) shares these keys, so two loaders naming the same request share one response.

The data cache that every chart shares (see the cache config key) keeps the responses it fetches under these keys. The same URL always matches, while different headers or another URL each get their own entry.

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

cacheKey("/data/fruits.csv");
cacheKey({url: "/api/graph.json", headers: {Authorization: "token"}});
cacheKey({url: "/api/graph.json", headers: {Authorization: "other"}});

Parameters

import {cacheKey} from "@d3plus/data";
requestrequiredunknown

The URL or request object being fetched.