@cloudflare/workers-response-store 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/dist/binding.js +13 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Point `main` at the installed service entrypoint:
|
|
|
30
30
|
"compatibility_date": "2026-09-16",
|
|
31
31
|
"compatibility_flags": ["nodejs_compat"],
|
|
32
32
|
"workers_dev": false,
|
|
33
|
-
"cache": { "enabled":
|
|
33
|
+
"cache": { "enabled": false },
|
|
34
34
|
"exports": {
|
|
35
35
|
"default": { "type": "worker", "cache": { "enabled": false } },
|
|
36
36
|
"ResponseStoreBinding": { "type": "worker", "cache": { "enabled": true } },
|
|
@@ -44,6 +44,8 @@ Point `main` at the installed service entrypoint:
|
|
|
44
44
|
}
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
Workers Cache stays off for the Worker as a whole and for `default`; only `ResponseStoreBinding` opts in. Entrypoints that are not listed inherit the Worker-wide setting, so enabling it would let Cloudflare serve responses from other entrypoints from cache before the Worker runs.
|
|
48
|
+
|
|
47
49
|
`CacheMetadata` is a declarative SQLite Durable Object export. Do not also add it to Wrangler `migrations`.
|
|
48
50
|
|
|
49
51
|
### Application Worker
|
|
@@ -154,7 +156,7 @@ This is the minimum integration loop. A framework can add its own cacheability r
|
|
|
154
156
|
"main": "src/worker.ts",
|
|
155
157
|
"compatibility_date": "2026-09-16",
|
|
156
158
|
"compatibility_flags": ["nodejs_compat"],
|
|
157
|
-
"cache": { "enabled":
|
|
159
|
+
"cache": { "enabled": false },
|
|
158
160
|
"exports": {
|
|
159
161
|
"default": { "type": "worker", "cache": { "enabled": false } },
|
|
160
162
|
"ResponseStoreBinding": { "type": "worker", "cache": { "enabled": true } },
|
|
@@ -169,6 +171,8 @@ This is the minimum integration loop. A framework can add its own cacheability r
|
|
|
169
171
|
}
|
|
170
172
|
```
|
|
171
173
|
|
|
174
|
+
Workers Cache stays off for the Worker as a whole and for `default`; only `ResponseStoreBinding` opts in. Entrypoints that are not listed inherit the Worker-wide setting, so enabling it would let Cloudflare serve responses from other entrypoints from cache before the Worker runs.
|
|
175
|
+
|
|
172
176
|
`CacheMetadata` is a declarative SQLite Durable Object export. Do not also add it to Wrangler `migrations`. Create the configured R2 bucket before deploying, then run `wrangler types` to generate `Env` from the completed configuration.
|
|
173
177
|
|
|
174
178
|
## API
|
package/dist/binding.js
CHANGED
|
@@ -350,10 +350,15 @@ var ResponseStoreBinding = class extends WorkerEntrypoint {
|
|
|
350
350
|
return entry !== null;
|
|
351
351
|
}, () => true);
|
|
352
352
|
pendingR2Reads.set(readKey, pending);
|
|
353
|
+
let cleared;
|
|
354
|
+
this.ctx.waitUntil(new Promise((resolve) => {
|
|
355
|
+
cleared = resolve;
|
|
356
|
+
}));
|
|
353
357
|
try {
|
|
354
358
|
return await read;
|
|
355
359
|
} finally {
|
|
356
360
|
if (pendingR2Reads.get(readKey) === pending) pendingR2Reads.delete(readKey);
|
|
361
|
+
cleared();
|
|
357
362
|
}
|
|
358
363
|
}
|
|
359
364
|
async writeR2Revision(objectKey, revision, body, customMetadata, expectedEtag) {
|
|
@@ -707,7 +712,13 @@ var ResponseStoreBinding = class extends WorkerEntrypoint {
|
|
|
707
712
|
reservation ??= await this.reserveWrite(metadata, cacheKey, cacheTags);
|
|
708
713
|
return this.storeResponse(metadata, request, response, options.revalidator, options.expiryBehavior === "miss" ? "miss" : "regenerate", reservation, cacheTags);
|
|
709
714
|
})();
|
|
710
|
-
|
|
715
|
+
let cleared = () => {};
|
|
716
|
+
if (options.coalesce) {
|
|
717
|
+
pendingPuts.set(pendingPutKey, write);
|
|
718
|
+
this.ctx.waitUntil(new Promise((resolve) => {
|
|
719
|
+
cleared = resolve;
|
|
720
|
+
}));
|
|
721
|
+
}
|
|
711
722
|
try {
|
|
712
723
|
const result = await write;
|
|
713
724
|
if (!result.published || !result.entry) return {
|
|
@@ -720,6 +731,7 @@ var ResponseStoreBinding = class extends WorkerEntrypoint {
|
|
|
720
731
|
};
|
|
721
732
|
} finally {
|
|
722
733
|
if (options.coalesce && pendingPuts.get(pendingPutKey) === write) pendingPuts.delete(pendingPutKey);
|
|
734
|
+
cleared();
|
|
723
735
|
}
|
|
724
736
|
}
|
|
725
737
|
async refresh(options) {
|