Basics
- About the web interface controls
- Always-on DDoS mitigation
- Browser recommendations when using the Fastly web interface
- Content and its delivery
- Fastly POP locations
- Getting started with Fastly
- How caching and CDNs work
- How Fastly's CDN Service works
- HTTP status codes cached by default
- Self-provisioned Fastly services
- Sign up and create your first service
- Working with services
Domains & Origins
Performance
Basics
Dictionaries
Domains & Origins
- Changing origins based on user location
- Connecting to origins
- Enabling global POPs
- Failover configuration
- IPv6 support
- Maintaining separate HTTP and HTTPS requests to origin servers
- Routing assets to different origins
- Setting up redundant origin servers
- Specifying an override host
- Using Fastly with apex domains
Request settings
Cache settings
Headers
Responses
Performance
- About Dynamic Servers
- Cache control tutorial
- Caching configuration best practices
- Controlling caching
- Creating and using pools with Dynamic Servers
- Creating and using server entries with Dynamic Servers
- Enabling API caching
- Enabling automatic gzipping
- Failure modes with large files
- HTTP/2 server push
- Implementing API cache control
- Making query strings agnostic
- Request collapsing
- Segmented Caching
- Serving stale content
- Setting Surrogate-Key headers based on a URL
- Setting Surrogate-Key headers for Amazon S3 origins
- Streaming Miss
Purging
Custom VCL
- Accept-Language header VCL features
- Authenticating before returning a request
- Basic authentication
- Creating location-based tagging
- Custom responses that don't hit origin servers
- Delivering different content to different devices
- Enabling URL token validation
- Guide to VCL
- Isolating header values without regular expressions
- Manipulating the cache key
- IP geolocation variables: Migrating to the new dataset
- Overriding which IP address the geolocation features use
- Response Cookie handling
- Support for the Edge-Control header
- Understanding the different PASS action behaviors
- Using edge side includes (ESI)
- VCL regular expression cheat sheet
Image optimization
Video
Access Control Lists
Monitoring and testing
Securing communications
Security measures
TLS
- Domain validation for TLS certificates
- Enabling HSTS through Fastly
- Forcing a TLS redirect
- Managing domains on TLS certificates
- Serving HTTPS traffic using certificates you manage
- Serving HTTPS traffic using Fastly-managed certificates
- Setting up free TLS
- TLS key and certificate replacement
- TLS termination
Web Application Firewall
Logging endpoints
- Log streaming: Amazon S3
- Log streaming: Microsoft Azure Blob Storage
- Log streaming: Cloud Files
- Log streaming: Datadog
- Log streaming: DigitalOcean Spaces
- Log streaming: Elasticsearch
- Log streaming: FTP
- Log streaming: Google BigQuery
- Log streaming: Google Cloud Storage
- Log streaming: Honeycomb
- Log streaming: Kafka
- Log streaming: Log Shuttle
- Log streaming: LogDNA
- Log streaming: Logentries
- Log streaming: Loggly
- Log streaming: Heroku's Logplex
- Log streaming: OpenStack
- Log streaming: Papertrail
- Log streaming: Scalyr
- Log streaming: SFTP
- Log streaming: Splunk
- Log streaming: Sumo Logic
- Log streaming: Syslog
Non-Fastly services
Streaming logs
Debugging techniques
Common errors
Account management
Billing
User access and control
Custom responses that don't hit origin servers
Last updated September 11, 2019
Fastly can send custom responses for certain requests that you don't want to hit your origin servers.
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. For example, if you wanted to restrict caching to a URL subtree that contains images and scripts, you could configure Fastly to return an HTTP 404 Not Found
response to requests for anything other than /Content/*
or /Scripts/*
. To illustrate how to implement this example, we'll show you how to create a response and corresponding request condition.
Follow these instructions to create an advance response:
- Log in to the Fastly web interface and click the Configure link.
- From the service menu, select the appropriate service.
- Click the Edit configuration button and then select Clone active. The Domains page appears.
- Click the Content link. The Content page appears.
-
Click the Set up advanced response button. The Create a synthetic response page appears.
- Fill out the Create a synthetic response fields as follows:
- In the Name field, type a human-readable name for the response. For example
Return Not Found
. - From the Status menu, select an HTTP code to return to the client. For example,
404 Not Found
. - In the MIME Type field, type the MIME type of the response. For example,
text/html
. - In the Response field, type the plaintext or HTML content to return to the client. For example
Page not found
.
- In the Name field, type a human-readable name for the response. For example
-
Click the Create button to create the response. The new response appears in the Responses area of the Content page.
Creating the request condition
Follow these instructions to attach a request condition to the response you just created:
-
Click the Attach a condition link next to the response that you just created. The Add a condition window appears.
-
Click the Create a new condition button. The Create a new condition window appears.
- 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. For example,
Return Not Found
. - In the Apply if field, type the request condition you want inserted into a VCL if statement. For example,
! ( req.url ~ "^/(Content|Scripts)/" )
. See below for more examples of request conditions.
-
Click the Save and apply to button. The Responses area now displays the condition that must be met in order for your response to begin being used.
- Click the Activate button to deploy your configuration changes.
Example request conditions
Respond only if URLs don't match a certain mask, in this case /Content/*
or /Scripts/*
:
1
! (req.url ~ "^/(Content|Scripts)/")
Respond only if URLs match /secret/*
or are Microsoft Word or Excel documents (*.doc
and *.xls
file extensions):
1
! (req.url ~ "^/secret/" || req.url ~ "\.(xls|doc)$")
Ignore POST and PUT HTTP requests:
1
req.method == "POST" || req.method == "PUT"
Deny a spider or crawler using user-agent
"annoying_robot"
:
1
req.http.user-agent ~ "annoying_robot"
Prevent a specific IP from connecting, in this case the IP 225.0.0.1
:
1
client.ip == "225.0.0.1"
Use geographic variables to block traffic from a specific location (e.g., China):
1
client.geo.country_code == "CN"
Match the client.ip
against a CIDR range, such as 240.24.0.0/16
(this requires first creating an ACL object in VCL):
1
client.ip ~ ipRangeObject