Include request ID in a synthetic response

Hey Folks,

Presenting an end user with an identifier when they encounter an issue on a web page can significantly enhance the troubleshooting process and improve the user experience for several reasons:

  1. Improved Support Efficiency: When a user contacts support with an error identifier, the support team can quickly locate the specific error in the logs or documentation. This reduces the time needed to understand the problem, as the error identifier acts as a direct reference to the issue.
  2. User Trust and Transparency: By presenting an error identifier, organizations show a level of transparency about the issues in their system. It reassures users that the error is recognized, logged, and potentially under investigation, which can help in maintaining trust.
  3. Facilitates Automated Support: Error identifiers can be used to automate part of the support process. For example, when a user enters an error code into a support form, the system can automatically provide them with known fixes, workarounds, or status updates on the issue.
  4. Error Localization: In a global application, error identifiers can help in localizing error messages. The actual text of the error message can be translated based on the user’s language preference, while the error identifier remains constant for reference across different languages.

I will show how to easily implement a synthetic page containing the request ID from Fastly when a block is returned from the Fastly Next-Gen WAF. Here is the fiddle that shows the implementation.

What is the fiddle doing?


We are storing the variable fastly_info.request_id in the request header so we can use it later. This is already done if you are using the NGWAF edge deployment in the ngwaf_config_init snippet.


When the response code from the origin or NGWAF edge deployment is equal to 416, enter the error subroutine.


Generate the synthetic content and include the request header req.http.x-fastly-ngwaf:requestid which will contain the value of the request ID.

Extra credit

The synthetic page may be customized further to call on JavaScript which may then localize the content that is rendered to end users. However, that specific implementation is outside of this example.


This is an example for how to customize a block page returned by Fastly’s Next-Gen WAF. Enjoy!

1 Like