Getting started
Basics
Domains & Origins
Performance

Configuration
Basics
Conditions
Dictionaries
Domains & Origins
Request settings
Cache settings
Headers
Responses
Performance
Custom VCL
Image optimization
Video

Security
Access Control Lists
Monitoring and testing
Securing communications
Security measures
TLS
Web Application Firewall

Integrations
Logging endpoints
Non-Fastly services

Diagnostics
Streaming logs
Debugging techniques
Common errors

Account info
Account management
Billing
User access and control

Reference

    Responses tutorial

      Last updated August 16, 2018

    Fastly allows you to create custom HTTP responses that are served directly from the cache without storing the page on a server. Responses are commonly used to serve small static assets that seldom change and maintenance pages that are served when origins are unavailable. This tutorial shows you how to create your own responses.

    Creating a quick response

    Fastly provides features that allow you to quickly enable and configure responses for a robots.txt file and 404 and 503 errors. For more information, see our guides on creating and customizing a robots.txt file and creating error pages with custom responses.

    Creating an advanced response

    You can create an advanced response to specify the HTTP status code, MIME type, and content of the response. An advanced response has three basic attributes:

    By setting these three attributes and adding a condition to the response, you can very quickly get one up and running on your service. To create an advance response, follow the steps below:

    1. Log in to the Fastly web interface and click the Configure link.
    2. From the service menu, select the appropriate service.
    3. Click the Configuration button and then select Clone active. The Domains page appears.
    4. Click the Content link. The Content page appears.
    5. Click the Set up advanced response button. The Create a synthetic response page appears.

      the text editor area of the Synthetic Response window

    6. Fill out the Create a synthetic response fields as follows:
      • In the Name field, type a human-readable name for the response (e.g., My first response).
      • From the Status menu, select the appropriate status (e.g., 200 OK).
      • In the MIME Type field, type the content type of the response (e.g., text/html).
      • In the Response field, type the response you want to appear when the conditions are met.
    7. Click the Create button to create your custom response.

    Your new response appears in the list of responses.

    Adding conditions

    To add a condition, follow the steps below:

    1. Click the Attach condition link to the right of the new response. The Create a new condition window appears.

      the Apply if field  associated with a new response

    2. Fill out the Create a new condition fields as follows:
      • From the Type menu, select the type of condition you want to create.
      • In the Name field, type a human-readable name for the condition so that it can be easily identified in the future.
      • In the Apply if field, type the condition under which the new response occurs. The condition should take the following format: req.url ~ "^/construction/" equals the request condition you're creating the response for.
      • In the Priority field, type a priority if needed. Condition priorities are only needed in "interesting" cases, and can usually be left at the default "10" for all response conditions.
    3. Click the Save and apply to button.
    4. Click the Activate button to deploy your configuration changes.

    Fastly now serves your custom response page when the condition is met.

    Back to Top