Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert cache key fields and cache ttl by status to their new formats #4776

Merged

Conversation

jafowler
Copy link
Contributor

@jafowler jafowler commented Dec 16, 2024

This PR aims to add support for transforming attribute for the page rules cache_key_fields and cache_ttl_by_status actions.

For cache_key_fields we're looking to migrate

query_string {
    ignore = true // or
    ignore = false
} 

to

query_string {
   exclude = ["*"] // or
   include = ["*"]
} 

As for cache_ttl_by_status we're looking to transform

resource "cloudflare_page_rule" {
	actions = [ 
        {
		cache_ttl_by_status = [ 
                  {
			codes = "200-299"
			ttl = 300
		},
                {
                          codes = "300-399"
                          ttl = 60
                },
                {
                          codes = "400-403"
                          ttl = -1
                },
                {
                          codes = "404"
                          ttl = 30
                },
                {
                          codes = "405-499"
                          ttl = -1
                },
                {
                          codes = "500-599"
                          ttl = 0
                }
            ]
	}
  ]
}

to

resource "cloudflare_page_rule"{
  actions = {
    cache_ttl_by_status = {
        "100-149" = "no-cache"
        "150-199" = "no-store"
        "200-299" = 300
        "300-399" = 60
        "400-403" = -1
        "404" = 30
        "405-499" = -1
        "500-599" = 0
    }
  }
}

Proof cache_ttl_by_status works:
image

@jacobbednarz
Copy link
Member

@jafowler is going to look into the cache_ttl_by_status = { ... } and cache_ttl_by_status = [ ... ] difference as there is a conflict here with what is expected and what is happening type wise.

@jafowler
Copy link
Contributor Author

we've decided to drop the grit transforms for cache_ttl_by_status due to the complexity of the grit itself. We will document the changes and keep the grit transforms for cache_key_fields.

@jacobbednarz jacobbednarz merged commit 94dd805 into cloudflare:next Dec 19, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants