Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Commit

Permalink
fix(static): return the original URL in case a static resource cannot…
Browse files Browse the repository at this point in the history
… get retieved for an ESI include

fixes #813
  • Loading branch information
trieloff committed May 2, 2019
1 parent d6c89f8 commit 453c724
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion static.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,23 @@ function deliverPlain(owner, repo, ref, entry, root, esi = false) {
'X-Static': 'Raw/Static',
},
};
}).catch(rqerror => error(rqerror.response.body.toString(), rqerror.statusCode));
}).catch(rqerror => {
if (esi) {
// the ESI failed, so we simply fall back to the original URL
// the browser will fetch it again, so let's cache the 404
// for five minutes, in order to prevent the static function
// from being called too often
return {
statusCode: 404,
headers: {
'Content-Type': 'text/plain',
'Cache-Control': 's-max-age=300',
},
body: entry
}
}
return error(rqerror.response.body.toString(), rqerror.statusCode)
});
}

/**
Expand Down

0 comments on commit 453c724

Please sign in to comment.