Using Cloud CDN

This page explains how to enable and disable Google Cloud CDN on a load balancing configuration.

Read the Overview for an introduction to Cloud CDN.

Before you begin

Cloud CDN uses HTTP(S) load balancing as the origin for cacheable content. You must use HTTP(S) load balancing as the origin of content cached by Cloud CDN.

Using gcloud

To use gcloud commands, install the gcloud command line interface.

If you haven't run the gcloud command previously, first run gcloud init to authenticate.

Alternatively, you can use Google Cloud Shell, which comes with gcloud already installed.

Using Cloud CDN with a backend service or backend bucket

You can enable Cloud CDN for an existing HTTP(S) load balancer backend service or backend bucket or enable it while creating a new one.

Enable Cloud CDN for an existing backend service or bucket

To enable Cloud CDN for an existing backend service or backend bucket:

Console


  1. Go to the Cloud CDN page in the Google Cloud Platform Console.
    Go to the Cloud CDN page
  2. Click Add origin.
  3. In the Origin pull-down menu, click Select origin.
  4. Select the origin for which you want to turn on CDN.
  5. Click Add.

You may also enable Cloud CDN from the load balancer page.

  1. Go to the Load balancing page in the Google Cloud Platform Console.
    Go to the Load balancing page
  2. Click the Edit button in your load balancer's row.
  3. Click Backend configuration.
  4. Click your existing backend service or backend bucket.
  5. Select the Enable Cloud CDN checkbox at the bottom of the right panel.
  6. Click Update.

gcloud


For a backend service:

gcloud compute backend-services update [BACKEND_SERVICE_NAME] \
    --enable-cdn

For a backend bucket:

gcloud compute backend-buckets update [BACKEND_BUCKET_NAME] \
    --enable-cdn

Enabling Cloud CDN while creating a backend service or bucket

To enable Cloud CDN when creating your HTTP(S) Load Balancing backend service or backend bucket, follow the instructions for creating a load balancer, but enable Cloud CDN when you create your backend service or bucket.

Console


  1. Go to the Load balancing page in the Google Cloud Platform Console.
    Go to the Load balancing page
  2. When creating a backend service or bucket, select the Enable Cloud CDN checkbox at the bottom of the right panel.
  3. Create the rest of your load balancer.

gcloud


For a backend service:

gcloud compute backend-services create [BACKEND_SERVICE_NAME] \
    --health-checks [HEALTH_CHECK] \
    --enable-cdn

For a backend bucket:

gcloud compute backend-buckets create [BACKEND_BUCKET_NAME] \
    --enable-cdn

Disabling Cloud CDN for a backend service

To disable Cloud CDN for backend services:

Console


To disable Cloud CDN for a single backend service or bucket, do the following. You cannot disable Cloud CDN for all backend services and buckets for an origin using this method.

  1. Go to the Cloud CDN page in the Google Cloud Platform Console.
    Go to the Cloud CDN page
  2. In the right side of the origin row, click the "three dot" menu button and select Edit.
  3. Uncheck the checkboxes of any backend services or backend buckets you want to stop from using Cloud CDN.
  4. Click Update.

To turn off Cloud CDN for all backend services and buckets for an origin, do the following.

  1. Go to the Cloud CDN page in the Google Cloud Platform Console.
    Go to the Cloud CDN page
  2. In the right side of the origin row, click the "three dot" menu button and select Remove.
  3. Click the Remove button to confirm.

You may also disable Cloud CDN from the load balancer page.

  1. Go to the Load balancing page in the Google Cloud Platform Console.
    Go to the Load balancing page
  2. Click the Edit button in your load balancer's row.
  3. Click Backend configuration.
  4. Click your existing backend service or backend bucket.
  5. Deselect the Enable Cloud CDN checkbox.
  6. Click Update.

gcloud


For a backend service:

gcloud compute backend-services update [BACKEND_SERVICE_NAME] \
    --no-enable-cdn

For a backend bucket:

gcloud compute backend-buckets update [BACKEND_BUCKET_NAME] \
    --no-enable-cdn

Disabling Cloud CDN does not invalidate or purge caches. If you turn Cloud CDN off and back on again, most or all of your cached content might still be cached. To prevent content from being used by the caches, you must invalidate that content.

Invalidating cached content

Sometimes you need to stop caches from serving objects they have cached. Cache invalidation causes Cloud CDN to stop serving the invalidated content. See Invalidating Cached Content for instructions on invalidating one or more objects in the caches.

What's next?

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud CDN Documentation