On an error, is it better to show a page or to redirect?
Short answer
In most cases, showing a page is better. The Show Content for Traffic Manager Errors and Show Content for Backend Service Errors actions return the selected Status Code value (e.g. 503), the address bar does not change, and when the problem is fixed the user returns to the site by refreshing the page; since the page is served from TR7, there is no dependency on another server. Redirect for Traffic Manager Errors and Redirect for Backend Service Errors return 302, hide the error code and require the target address to be up; they are chosen when a status site hosted outside TR7 is needed or when pages that are not found need to be sent to a search page.
How Does It Work?
- The request falls into an error: either TR7 has to produce a response (the Backend Service cannot be reached, timeout) or the Backend Service returns an error code.
- If a page is shown: TR7 returns the content page with the selected status code within the same request; the client receives a single response, and the address does not change.
- If it is redirected: TR7 returns
302and aLocationheader; the browser makes a new request to the target address. The response of the target (mostly200) is the result the user sees.
Comparison
| Showing a page | Redirecting | |
|---|---|---|
| Status code | Selected in the Status code field (default 200; a suitable code must be selected) | 302; then the code of the target page |
| Address bar | The same address stays | Switches to the target address |
| When the problem is fixed | The user returns to the site by refreshing the page | The user stays at the target address |
| Dependency | None; the page is served from TR7 | The target address must be reachable |
| Monitoring tools and search engines | The error code is seen, and the temporary situation is understood | The actual error code is lost |
| POST requests | Not affected | The browser goes to the target with GET |
| API clients | A page whose Content type is application/json can be returned | The redirect breaks the response the client expects |
| Dynamic target | - | In Redirect for Backend Service Errors, the Redirect location field can append the path that was not found to the target with a Smart Variable |
| Page size | Cannot exceed the Buffer Size(kB) value of the vService minus 2 kB (default 128 kB) | The target page can be of any desired size |
Error Page and Error Redirect in TR7
All four actions are defined with Load Balancer → Actions → Add, take no condition, and once added to the Actions field of the vService, take effect only on the codes selected in the Error Codes list. They work only on the HTTP vService.
| Source of the error | Showing a page | Redirecting | Setup |
|---|---|---|---|
| TR7 (the Backend Service cannot be reached, timeout) | Show Content for Traffic Manager Errors | Redirect for Traffic Manager Errors | Can I show a custom page for 503/502/504 errors generated by TR7 itself? |
| Backend Service (404, 500…) | Show Content for Backend Service Errors | Redirect for Backend Service Errors | Can I show a custom error page when the backend returns 404 or 500? |
The pages are prepared in the Content Pages profile (What is the Content Pages profile; how do I prepare my own HTML page?).
When to Use Which?
- Showing a page: Maintenance and outage pages, APIs, and situations where monitoring tools need to see the error.
- Redirecting: Situations where the outage information is given on a status site hosted outside TR7, or where pages that are not found are sent to a search page.
Common Misconceptions
- "Redirecting is better for search engines." The client receives 302 and then the 200 response of the target; the actual error code is lost, and the error page may be treated as content.
- "Showing a page always returns the correct code." Status code is 200 by default; a suitable code must be selected separately.
- "The target address can be on the same vService." If the target also gives the same error, the user enters a loop; the target is hosted outside TR7 or on another vService.
- "A large page with images is served from TR7 without problems." The page must fit in the buffer size; images are kept small or pulled from an external address.
How it is done in the documentation
