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