Last updated October 04, 2016
How long Fastly caches content
The maximum amount of time we cache content depends on a number of factors including the TTL (Time To Live) and Grace Period, how often an object gets accessed, and how busy other customers are. Setting TTL and Grace Period to a week, possibly even two weeks should be absolutely fine. For more information about controlling how long Fastly caches your resources, start with our Cache Control Tutorial.
In general, we will honor any cache-control headers you send to us from your origin; however, if you do not send any cache-control headers, you will most likely reach the Default TTL limit for your service. You can change this limit on the Configuration page.
Changing caching times for different users
You can change the caching times for different users through Surrogate-Control headers defined by the W3C. If, for example, you wanted Fastly to cache something for a month (clearing with API purges, if necessary) but you also wanted to set a maximum age of a single day for users viewing that object in a browser, then you could return the HTTP header:
Surrogate-Control: max-age=2629744 Cache-Control: max-age=86400
The Surrogate Control header in this example tells Fastly to cache the object for a maximum of 2629744 seconds (one month). The Cache Control header in this example tells the browser to cache the object for a maximum of 86400 seconds (1 day).
For more information about controlling caching, see our Cache Control Tutorial.
Conditionally preventing pages from caching
To conditionally prevent pages from caching, follow the steps below.
- 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 service version page appears.
- Click the Settings tab. The Settings page appears.
Click the Create cache setting button to create a new cache setting. The Create a new cache setting page appears.
- Create a new cache setting and then click the Create button. The new cache setting you created appears on the Settings page.
Click the Attach a condition link to the right of the newly created cache setting. The Create a new cache condition window appears.
- Create a condition that matches the URLs you want and then click the Save and apply to button.
In this example, we set the condition to look for URLs containing
/assets. If the condition finds them, the URLs should be cached. If the condition doesn't find them, the URLs are explicitly not cached by the apply if statement shown above.
- Click the Activate button to deploy your configuration changes.
TIP: You can use these steps to override default caching based on a backend response.
Caching action descriptions
You can use actions to tell Fastly what to do with cached objects and what to do with additional cache configurations as a result. The following actions are available:
- Do nothing now - Only set the TTL or stale TTL.
- Deliver - Deliver the object to the client. Usually returned from
- Pass - Pass the request and subsequent response to and from the origin server without caching the object. Usually returned from
- Restart - Restart the request processing for the object. You can restart the processing of the whole transaction. Changes to the
reqobject are retained.
Back to Top