Skip to content

Commit

Permalink
[fix] return 404 instead of 200 for stale assets
Browse files Browse the repository at this point in the history
  • Loading branch information
raduab committed Sep 19, 2022
1 parent d26af53 commit 8c8ca87
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/adapter-cloudflare/src/worker.js
Expand Up @@ -20,6 +20,7 @@ const worker = {
// static assets
if (pathname.startsWith(prefix)) {
res = await env.ASSETS.fetch(req);
if (!res.ok) return res

const cache_control = pathname.startsWith(prefix + 'immutable/')
? 'public, immutable, max-age=31536000'
Expand Down Expand Up @@ -65,7 +66,7 @@ const worker = {

// Writes to Cache only if allowed & specified
pragma = res.headers.get('cache-control');
return pragma ? Cache.save(req, res, context) : res;
return pragma && res.ok ? Cache.save(req, res, context) : res;
}
};

Expand Down

0 comments on commit 8c8ca87

Please sign in to comment.