Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bright-eggs-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudflare/workers-shared": patch
---

The asset-worker now uses a shorter 10-second TTL for cached assets, down from 60 seconds. This ensures that asset updates are reflected more quickly during development and deployment, reducing the window where stale assets might be served.
4 changes: 2 additions & 2 deletions packages/workers-shared/asset-worker/src/utils/kv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export async function getAssetWithMetadataFromKV(
);

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

if (retriedAsset.value !== null && sentry) {
Expand Down
2 changes: 1 addition & 1 deletion packages/workers-shared/asset-worker/tests/kv.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe("[Asset Worker] Fetching assets from KV", () => {
expect(spy).toHaveBeenCalledTimes(2);
});

it("should retry on 404 and cache with 30s ttl", async () => {
it("should retry on 404 with short cache ttl", async () => {
let attempts = 0;
spy.mockImplementation(() => {
if (attempts++ === 0) {
Expand Down
Loading