Temporarily disabling caching

Caching can be disabled:

  • at the individual URL level,
  • at the browser level, and
  • at the site level.

Disabling caching at the individual URL level

To disable caching at the individual URL level:

  1. Create a request setting that always forces a pass.
  2. Add a condition to the request setting that looks for specific URLs.
  3. Activate the new version of your service to enable the setting.

Disabling caching at the browser level

Theoretically, all browsers should follow the stated rules of the HTTP standard. In practice, however, some browsers don't strictly follow these rules. The following combination of headers seems to force absolutely no caching with every browser we've tested.

Cache-Control: no-cache, no-store, private, must-revalidate, max-age=0, max-stale=0, post-check=0, pre-check=0
Pragma: no-cache
Expires: 0

In addition, IE8 has some odd behavior to do with the back button. Adding Vary: * to the headers seems to fix the problem.

WARNING: If you want your content cached in Fastly but not cached on the browser, you must not add these headers on your origin server. Instead, add these as new Headers on the Content page and be sure the Type is set to Response.

Disabling caching at the site level

You can disable caching at the site level by creating a VCL Snippet to pass on all requests to your service:

  1. Log in to the Fastly control panel.

  2. From the Home page, select the appropriate service. You can use the search box to search by ID, name, or domain.

  3. Click Edit configuration and then select the option to clone the active version.

  4. Click VCL.

  5. Click VCL snippets.

  6. Click Add snippet.

  7. Fill out the Add VCL snippet fields as follows:

    • Using the Type controls, select Regular to create a regular VCL snippet.
    • In the Name field, enter an appropriate name (e.g., Pass All Requests).
    • Using the Placement controls, select Within subroutine.
    • From the Subroutine menu, select recv (vcl_recv).
    • (Optional) In the Priority field, enter the order in which you want the snippet to execute. Lower numbers execute first.
    • In the VCL editor, add the following code:
    return(pass);
  8. Click Add to create the snippet.

  9. Click Activate to deploy your configuration changes.

All requests will continue to be passed until you remove return(pass); from vcl_recv in your VCL or you delete this snippet.