Error Responses is an Azion Edge Application feature that allows you to customize error pages for users based on the status code received from the origin.
When a user requests content from an edge application, Azion sends the request to the origin servers. As a response, the origin sends back an HTTP status code, which indicates whether or not the request has been completed.
HTTP status codes are three-digit numbers, grouped into five categories:
- Informational responses (1xx): the connection status or progress before completing the request.
- Successful responses (2xx): the request was successfully received, understood, accepted, and processed by the origin.
- Redirection messages (3xx): in order to fulfill the request, there must be a redirect.
- Client error responses (4xx): the request couldn’t be completed due to an apparent error on the client’s side.
- Server error responses (5xx): the server is unable to process the request.
With Error Responses, you can customize how your application will handle Client (4xx) and Server (5xx) error types. This way, when a request is made to a URL that can’t be found at the origin or when the server is unable to respond, the user will be redirected to a custom error page, whose contents can be cached.
ImplementationSection titled Implementation
|Edge Application first steps
|Customizing error page
|How to customize an error response page
Status CodeSection titled Status Code
The code Azion receives when connecting to the origin.
Error Caching TTLSection titled Error Caching TTL
Defines the time in seconds that the error page will remain in cache before it’s refreshed.Learn more about expiration settings
Path to the file (usually in HTML) with the content of the error page that will be delivered. This path is appended to your application’s domain. For example:
Custom Status CodeSection titled Custom Status Code
Status code that will be delivered to the user instead of the original one. For example, you may define that the
404 code be delivered in response to a
Set OriginSection titled Set Origin
The origin in which the URI file is located. Can only be altered if a URI is provided. Must be configured using Origins.Learn more about Origins
Available error status codesSection titled Available error status codes
|400: Bad Request
|Request error caused by invalid parameters, missing required parameters, or others.
|Error resulting from a lack of the
Authentication HTTP header.
|Lack of user permissions to execute the operation.
|404: Not Found
|The resource requested doesn’t exist.
|405: Method Not Allowed
|The requested method can’t be applied to the URL.
|406: Not Acceptable
Accept header wasn’t found in the HTTP request or header contains content whose formatting or version isn’t supported by the API.
|408: Request Timeout
|The server informs that the request is coming in slower than the server is prepared to wait. This means the server would like to terminate the connection.
This response is often used since some browsers, like Chrome, Firefox 27+, or IE9, use HTTP pre-connection to speed up navigation. Also, some servers take down the connection without sending this message.
|Conflict in the execution of the request, such as creating an existing registry.
|This response is sent when the requested content was permanently deleted from the server, without a preset redirect address. If this error happens, any caches or links to this resource should be removed.
The HTTP specification describes that this code should be used for “limited promotional services”. APIs shouldn’t be made to indicate which resources were removed with this status code.
|411: Length Required
|The server has rejected the request because the header
Content-Length is undefined but required by the server.
|414: URI Too Long
|The requested URI is larger than the server’s limits.
|415: Unsupported Media Type
|The media format of the requested data is unsupported by the server, so the server rejects it.
|416: Request Range Not Satisfiable
|The value specified by the
Range header couldn’t be filled; it’s likely that it’s out of range of the target URI data.
|426: Upgrade Required
|The server refuses to execute the requisition using the current protocol, but it’ll be ready to do so after the client updates to a different protocol. The server sends an
Upgrade header response to indicate the required protocols.
|429: Too Many Requests
|The request was temporarily rejected for exceeding operation limits. The client must wait until the moment defined in the
X-Ratelimit-Reset and try again.
|431: Request Header Fields Too Large
|The request’s headers are too long or too many cookies were sent in the request.
|500: Internal Server Error
|Unintentional error, fault unidentified in the processing of the request.
|501: Not Implemented
|The request method is unsupported by the server and can’t be modified. The only methods required for servers to support (and thus shouldn’t return this code) are GET and HEAD.
|502: Bad Gateway
|This error response means that the server, working as a gateway in order to obtain a necessary response to manipulate the request, obtained an invalid response.
|503: Service Unavailable
|The server isn’t ready to handle the request. Common causes are an overloaded server or a server under maintenance. Next to this response, a friendly page explaining the problem should be sent.
These responses should be used for temporary conditions and the
Retry-After header should contain the estimated time to recover the service. The webmaster should also be careful with the caching related headers that are sent with this response, since these temporary condition responses shouldn’t normally be cached.
|504: Gateway Timeout
|This error response is sent when the server is acting as a gateway and doesn’t obtain a response in time.
|505: HTTP Version Not Supported
|The HTTP version used in the request isn’t supported by the server.