Skip to content
This repository has been archived by the owner on Feb 25, 2022. It is now read-only.

Commit

Permalink
fix(vcl): move error from fetch to deliver
Browse files Browse the repository at this point in the history
  • Loading branch information
trieloff committed Jun 11, 2019
1 parent 05eeed9 commit 061fa10
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions layouts/fastly/helix.vcl
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ sub hlx_deliver_type {
call hlx_deliver_pipeline;
} elsif (req.http.X-Request-Type == "Static") {
call hlx_deliver_static;
} elsif (req.http.X-Request-Type == "Error") {
call hlx_deliver_error;
} elsif ((resp.status == 404 || resp.status == 204) && !req.http.X-Disable-Static && req.restarts < 1 && req.http.X-Request-Type != "Proxy") {
# That was a miss. Let's try to restart, but only restart once
set resp.http.X-Status = resp.status + "-Restart " + req.restarts;
Expand All @@ -649,8 +651,8 @@ sub hlx_deliver_type {
* 1. either the error page could be delivered from GitHub, then set the correct status code and deliver it
* 2. no error page could be found, so set the correct status code and deliver a fallback
*/
sub hlx_fetch_error {
set req.http.X-Trace = req.http.X-Trace + "; hlx_fetch_error(" + beresp.status + ")";
sub hlx_deliver_error {
set req.http.X-Trace = req.http.X-Trace + "; hlx_deliver_error(" + beresp.status + ")";
if (beresp.status == 200) {
# TODO: fix headers
} else {
Expand Down Expand Up @@ -1174,11 +1176,7 @@ sub vcl_fetch {
set beresp.ttl = 60s;
}
}

if (req.http.X-Request-Type == "Error") {
# check the response from /404.html, /500.html, etc.
call hlx_fetch_error;
}

call hlx_fetch_static;

if (beresp.http.X-ESI == "enabled" || req.http.x-esi) {
Expand Down

0 comments on commit 061fa10

Please sign in to comment.