How to set error pages
With this guide, you’ll modify the default error response of your application, setting a cache TTL for each error received from the origin.
There are separate instructions for API v3 using legacy Error Responses settings and API v4 using the new Custom Pages product.
Configure your application to handle error responses from the origin using Custom Pages. Azion allows you to set a cache TTL for error pages, a custom path, or deliver another HTTP code in the response without needing to change the source code of your application.
- Access Azion Console > Custom Pages.
- Click + Custom Page.
- In the Page Codes section, click + Custom Page Code to add a page for a chosen status code. For example:
404
. - In the new Page Code field, select the status code you want to customize.
- In the Connector field, select the Connector that is fetching the data from your origin.
6 In the Page Path field, add a path to an error page created in the source. For example:
/error/404
. - In Response TTL, set the cache time-to-live (TTL), in seconds.
- In the Response Custom Status Code field, customize the HTTP status that’ll be received by the user.
- Click the Apply button.
Now let’s bind the Custom Page to your Workload.
- Access Azion Console > Workloads.
- Edit the desired Workload.
- In the Deployment Settings section, select your Custom Page.
- Click the Save button.
When errors are received from the Connector, your application will cache and display the error page based on the new configuration.
Configure your application to handle error responses from the origin using Error Responses. Azion allows you to set a cache TTL for error pages, a custom path, or deliver another HTTP code in the response without needing to change the source code of your application.
With this guide, you’ll modify the default error response of your application, setting a cache TTL for each error received from the origin.
- Access Azion Console > Applications.
- Click the application you want to configure.
- Select the Error Responses tab.
In the Error Responses section, the Status Code field can’t be modified. This field represents every error status code received from the origin. The Default Response TTL field allows you to customize the cache TTL for every status code received.
- In Default Response TTL, set the cache time-to-live (TTL), in seconds, for all error pages.
- Click the + Error Response button.
- In the new Status Code field, select the status code you want to customize. For example:
404
. - Add a cache TTL in the Custom Response TTL field.
You can also determine a specific path from your origin that will be delivered to the user and a custom status code in the response. These modifications are optional.
- In the Page Path field, add a path to an error page created in the source. For example:
/error/404
. - In the Response Status Code field, customize the HTTP status that’ll be received by the user.
- In the Set Origin section, select the origin of error page URIs.
- Click the Save button.
When errors are received from the origin, your application will cache and display the error page based on the new configuration.