Skip to content

Commit 843febf

Browse files
committed
WC-4389 Reduce ttl to 10s for asset-worker
1 parent 8520a9c commit 843febf

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

.changeset/bright-eggs-draw.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/workers-shared": patch
3+
---
4+
5+
Modify TTL from 60s to 10s.

packages/workers-shared/asset-worker/src/utils/kv.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ export async function getAssetWithMetadataFromKV(
2323
);
2424

2525
if (asset.value === null) {
26-
// Don't cache a 404 for a year by re-requesting with a minimum cacheTtl
26+
// Don't cache a 404 for a year by re-requesting with a short cacheTtl
2727
const retriedAsset =
2828
await assetsKVNamespace.getWithMetadata<AssetMetadata>(assetKey, {
2929
type: "stream",
30-
cacheTtl: 60, // Minimum value allowed
30+
cacheTtl: 10,
3131
});
3232

3333
if (retriedAsset.value !== null && sentry) {

packages/workers-shared/asset-worker/tests/kv.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe("[Asset Worker] Fetching assets from KV", () => {
7878
expect(spy).toHaveBeenCalledTimes(2);
7979
});
8080

81-
it("should retry on 404 and cache with 30s ttl", async () => {
81+
it("should retry on 404 with short cache ttl", async () => {
8282
let attempts = 0;
8383
spy.mockImplementation(() => {
8484
if (attempts++ === 0) {

0 commit comments

Comments
 (0)