Remove prefetch boolean from JS sources - no reason to ever not use i… (#353)

* Remove prefetch boolean from JS sources - no reason to ever not use it

* JS optimization for header fetches on etag invalidation [#90]

* If promises are shared between requests, only the first invalidation makes the header request.
* If promises are not shared, simply delete the key.

* JS 3.0.3 [#90]

* update CHANGELOG
This commit is contained in:
Brandon Liu
2024-02-05 15:57:30 +08:00
committed by GitHub
parent c43e73a813
commit b229c1a8c7
8 changed files with 55 additions and 43 deletions

View File

@@ -289,12 +289,8 @@ test("cache getDirectory", async () => {
"1"
);
let cache = new SharedPromiseCache(6400, false);
let header = await cache.getHeader(source);
assert.strictEqual(cache.cache.size, 1);
cache = new SharedPromiseCache(6400, true);
header = await cache.getHeader(source);
const cache = new SharedPromiseCache(6400);
const header = await cache.getHeader(source);
// prepopulates the root directory
assert.strictEqual(cache.cache.size, 2);
@@ -358,7 +354,7 @@ test("weak etags", async () => {
// handle DigitalOcean case returning 200 instead of 206
test("cache pruning by byte size", async () => {
const cache = new SharedPromiseCache(2, false);
const cache = new SharedPromiseCache(2);
cache.cache.set("0", { lastUsed: 0, data: Promise.resolve([]) });
cache.cache.set("1", { lastUsed: 1, data: Promise.resolve([]) });
cache.cache.set("2", { lastUsed: 2, data: Promise.resolve([]) });