Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Google Cloud CDN cache invalidation

I have 2 environments : prod and staging. I deploy static website files on cloud storage buckets. Separate resources have been created for each environment on google cloud:

  1. subdomains: sub.example.com and sub-staging.example.com;

  2. load balancers with backend buckets.

All resources are separated, created via terraform.

When I click the “Invalidate” button on the “Caching” tab of the “Load balancer details” page, the cache is invalidated for staging and prod load balancers. BUT when I click “Invalidate” button for prod load balancer, then cache invalidated only for prod load balancer.

ThobbR_0-1722231680933.png

Same behavior when I run the command "gcloud compute url-maps invalidate-cdn-cache my-lb-staging --path "/*" --async".

I'm new to devops and google cloud, please help me understand what direction to take to figure out what the problem is.

0 1 659
1 REPLY 1

Hi @ThobbR,

Welcome to Google Cloud Community!

It is possible that you're seeing cache invalidation across your staging and production environments due to a configuration issue at a higher level within your GCP infrastructure.

I would look into the following to see if there are configuration issues causing this behavior:

  • Check for any Global HTTP(S) Load Balancers in the Load Balancing section of your GCP and examine the frontend configuration such as host and path rules to see if it directs traffic for both your staging and production subdomains. If you're using a shared Global HTTP(S) Load Balancer, you'll need to create separate global load balancers for your staging and production environments.
  • Review and refine your CDN configuration if needed. Check the cache key settings and ensure differentiation between staging and production. 
  • Try isolating the issue by trying to invalidate a specific file or directory to confirm if the issue is within the invalidation mechanism or resource association.

Hope this helps.