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 the gcloud command line tool

The steps on this page can be completed using the Google Cloud Platform Console UI or the gcloud command line tool.

You can access the gcloud command line tool in two ways:

  • Install the Google Cloud SDK by following the instructions at /sdk/downoads. If you haven't used the gcloud command line tool previously, first run gcloud init to authenticate.{: .special }

  • Use Google Cloud Shell, which comes with gcloud already installed.

Enabling Cloud CDN

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 backend 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.

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 backend 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 backend 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 backend 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 --gcs-bucket-name=[BUCKET_NAME]

Disabling Cloud CDN

To disable Cloud CDN for a backend service or backend bucket:

Console

To disable Cloud CDN for a single backend service or backend bucket, 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 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 backend 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.

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?

  • Learn more about Cloud CDN caching.
  • For information on using Cloud CDN in Google Kubernetes Engine, see Configuring CDN.
  • View logs to check whether Cloud CDN is serving responses from cache.
  • If you run into trouble, refer to the troubleshooting page page for information on common problems and solutions.
Was this page helpful? Let us know how we did:

Send feedback about...

Cloud CDN Documentation