Old assets availability with `--old-asset-ttl`

I'm trying to make outdated assets from the previous deployment available using --old-asset-ttl option (Thanks for @Peter Belbin https://github.com/cloudflare/workers-sdk/pull/3384). Unfortunately, assets aren't available using the old link from the browser after deployment. They are still in KV as expected but are not present in __STATIC_CONTENT_MANIFEST anymore. So can't be reached from browser by initial name (without hash prefix). I'm using a custom build with webpack to build my React app (not Wrangler internal bundler) and npx wrangler deploy -c wrangler.toml -e "<MY_ENV>" --old-asset-ttl=43200 to deploy. And finally, my fetch func in Worker is very simple
export default {
async fetch(request, env, ctx) {
const additionalHeaders = await getAdditionalHeaders(request, env)
const page = await getAssetFromKV(
{
request,
waitUntil: ctx.waitUntil.bind(ctx),
},
{
ASSET_NAMESPACE: env.__STATIC_CONTENT,
ASSET_MANIFEST: assetManifest,
mapRequestToAsset: serveSinglePageApp,
},
)

return addHeaders(request, new Response(page.body, page), env, additionalHeaders)
},
}
export default {
async fetch(request, env, ctx) {
const additionalHeaders = await getAdditionalHeaders(request, env)
const page = await getAssetFromKV(
{
request,
waitUntil: ctx.waitUntil.bind(ctx),
},
{
ASSET_NAMESPACE: env.__STATIC_CONTENT,
ASSET_MANIFEST: assetManifest,
mapRequestToAsset: serveSinglePageApp,
},
)

return addHeaders(request, new Response(page.body, page), env, additionalHeaders)
},
}
What I'm missing in using --old-asset-ttl? How to make it work?
2 Replies
Peter Belbin
Peter Belbin4mo ago
Hmmmmmmm. I think this could be considered a bug. Seems like, for your use case, the manifest should be including the not-yet-expired asset details so that the mapping can be successful until they expire.
Serhii Bilonoh
Serhii BilonohOP4mo ago
I got it. Thanks for taking a look!
Want results from more Discord servers?
Add your server