且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使后端的Google Cloud CDN缓存无效

更新时间:2022-12-31 08:40:12

因此,我对impossibility错了.我找到了相应的REST API方法( https://cloud. google.com/compute/docs/reference/rest/v1/urlMaps/invalidateCache ):

So, I was wrong about impossibility. I found the respective REST API method (https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps/invalidateCache):

POST https://www.googleapis.com/compute/v1/projects/{project}/global/urlMaps/{resourceId}/invalidateCache

这是使用官方gem 的示例Ruby代码. >:

And here is a sample Ruby code to work with it using official gem:

require 'google/apis/compute_v1'

service = Google::Apis::ComputeV1::ComputeService.new
service.authorization =
  Google::Auth::ServiceAccountCredentials
    .make_creds(
      json_key_io: File.open('/path/to/credentials.json'),
      scope:       [Google::Apis::ComputeV1::AUTH_COMPUTE]
    )
service.invalidate_url_map_cache(
   'some-gcloud-project-id',
   'some-url-map',
   nil,
   request_id: SecureRandom.uuid
)