File tree 4 files changed +12
-6
lines changed
4 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,7 @@ describe.each(SupportedPHPVersions)(
150
150
type : 'response' ,
151
151
response : new PHPResponse (
152
152
404 ,
153
- { 'x-file-type ' : [ 'static ' ] } ,
153
+ { 'x-backfill-from ' : [ 'remote-host ' ] } ,
154
154
new TextEncoder ( ) . encode ( '404 File not found' )
155
155
) ,
156
156
} ;
@@ -164,7 +164,7 @@ describe.each(SupportedPHPVersions)(
164
164
expect ( response ) . toEqual ( {
165
165
httpStatusCode : 404 ,
166
166
headers : {
167
- 'x-file-type ' : [ 'static ' ] ,
167
+ 'x-backfill-from ' : [ 'remote-host ' ] ,
168
168
} ,
169
169
bytes : expect . any ( Uint8Array ) ,
170
170
errors : '' ,
Original file line number Diff line number Diff line change @@ -53,7 +53,7 @@ async function defaultRequestHandler(event: FetchEvent) {
53
53
const workerResponse = await convertFetchEventToPHPRequest ( event ) ;
54
54
if (
55
55
workerResponse . status === 404 &&
56
- workerResponse . headers . get ( 'x-file-type ' ) === 'static '
56
+ workerResponse . headers . get ( 'x-backfill-from ' ) === 'remote-host '
57
57
) {
58
58
const request = await cloneRequest ( event . request , {
59
59
url,
Original file line number Diff line number Diff line change @@ -55,14 +55,14 @@ initializeServiceWorker({
55
55
const workerResponse = await convertFetchEventToPHPRequest ( event ) ;
56
56
if (
57
57
workerResponse . status === 404 &&
58
- workerResponse . headers . get ( 'x-file-type ' ) === 'static '
58
+ workerResponse . headers . get ( 'x-backfill-from ' ) === 'remote-host '
59
59
) {
60
60
const { staticAssetsDirectory } = await getScopedWpDetails (
61
61
scope !
62
62
) ;
63
63
if ( ! staticAssetsDirectory ) {
64
64
const plain404Response = workerResponse . clone ( ) ;
65
- plain404Response . headers . delete ( 'x-file-type ' ) ;
65
+ plain404Response . headers . delete ( 'x-backfill-from ' ) ;
66
66
return plain404Response ;
67
67
}
68
68
Original file line number Diff line number Diff line change @@ -261,7 +261,13 @@ try {
261
261
type : 'response' ,
262
262
response : new PHPResponse (
263
263
404 ,
264
- { 'x-file-type' : [ 'static' ] } ,
264
+ {
265
+ 'x-backfill-from' : [ 'remote-host' ] ,
266
+ // Include x-file-type header so remote asset
267
+ // retrieval continues to work for clients
268
+ // running a prior service worker version.
269
+ 'x-file-type' : [ 'static' ] ,
270
+ } ,
265
271
new TextEncoder ( ) . encode ( '404 File not found' )
266
272
) ,
267
273
} ;
You can’t perform that action at this time.
0 commit comments