cdn-kit
v0.0.3
Published
Dependency-free helpers for CDN URLs and cache headers.
Readme
CDN Kit
Dependency-free helpers for CDN URLs and cache headers.
npm i cdn-kitimport { cdnUrl, immutableCacheControl, varyHeader } from "cdn-kit";
const src = cdnUrl("https://cdn.example", "images/hero.jpg", {
query: { w: 1200 },
});
const cacheControl = immutableCacheControl();
const vary = varyHeader(["Accept", "DPR"]);cdn-kit formats values; it does not fetch, upload, transform, or cache files.
API
cdnUrl(origin, path, options?)joins a CDN URL and sorted query parameters.immutableCacheControl(maxAge?)returns a long-lived immutable cache policy.varyHeader(names)returns a deduplicatedVaryheader value.
Development
npm test --workspace=cdn-kitMIT
