INNER CODE UNIT · Go

purgeCloudflareCache

bliporg/blip · ci/lua_docs_deploy_prod/main.go:316

func purgeCloudflareCache() error {
	url := fmt.Sprintf("https://api.cloudflare.com/client/v4/zones/%s/purge_cache", CLOUDFLARE_ZONE_ID)
	jsonStr := []byte(`{"purge_everything":true}`)
	// Only Enterprise customers are permitted to purge by Tag, Host or Prefix.
	// jsonStr := []byte(`{"hosts": ["cu.bzh"]}`)
	// Purge by file path
	// jsonStr := []byte(`{"files": ["https://app.cu.bzh/file1", "https://app.cu.bzh/file2"]}`)

	req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonStr))
	if err != nil {
		return err
	}

	req.Header.Set("Authorization", "Bearer "+CLOUDFLARE_API_TOKEN)
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{}
	resp, err := client.Do(req)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…