File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
adapter-cloudflare-workers/files Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ const static_asset_manifest = JSON.parse(static_asset_manifest_json);
66
77const server = new Server ( manifest ) ;
88
9- const prefix = `/${ manifest . appDir } /immutable/ ` ;
9+ const prefix = `/${ manifest . appDir } /` ;
1010
1111export default {
1212 /**
@@ -23,11 +23,15 @@ export default {
2323 const res = await get_asset_from_kv ( req , env , context ) ;
2424 if ( is_error ( res . status ) ) return res ;
2525
26+ const cache_control = url . pathname . startsWith ( prefix + 'immutable/' )
27+ ? 'public, immutable, max-age=31536000'
28+ : 'no-cache' ;
29+
2630 return new Response ( res . body , {
2731 headers : {
28- // include original cache headers, minus cache-control which
32+ // include original headers, minus cache-control which
2933 // is overridden, and etag which is no longer useful
30- 'cache-control' : 'public, immutable, max-age=31536000' ,
34+ 'cache-control' : cache_control ,
3135 'content-type' : res . headers . get ( 'content-type' ) ,
3236 'x-robots-tag' : 'noindex'
3337 }
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import * as Cache from 'worktop/cfw.cache';
44
55const server = new Server ( manifest ) ;
66
7- const prefix = `/${ manifest . appDir } /immutable/ ` ;
7+ const prefix = `/${ manifest . appDir } /` ;
88
99/** @type {import('worktop/cfw').Module.Worker<{ ASSETS: import('worktop/cfw.durable').Durable.Object }> } */
1010const worker = {
@@ -20,11 +20,15 @@ const worker = {
2020 if ( pathname . startsWith ( prefix ) ) {
2121 res = await env . ASSETS . fetch ( req ) ;
2222
23+ const cache_control = pathname . startsWith ( prefix + 'immutable/' )
24+ ? 'public, immutable, max-age=31536000'
25+ : 'no-cache' ;
26+
2327 res = new Response ( res . body , {
2428 headers : {
25- // include original cache headers, minus cache-control which
29+ // include original headers, minus cache-control which
2630 // is overridden, and etag which is no longer useful
27- 'cache-control' : 'public, immutable, max-age=31536000' ,
31+ 'cache-control' : cache_control ,
2832 'content-type' : res . headers . get ( 'content-type' ) ,
2933 'x-robots-tag' : 'noindex'
3034 }
You can’t perform that action at this time.
0 commit comments