# Page Rules ## List Page Rules `client.PageRules.List(ctx, params) (*[]PageRule, error)` **get** `/zones/{zone_id}/pagerules` Fetches Page Rules in a zone. ### Parameters - `params PageRuleListParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Direction param.Field[PageRuleListParamsDirection]` Query param: The direction used to sort returned Page Rules. - `const PageRuleListParamsDirectionAsc PageRuleListParamsDirection = "asc"` - `const PageRuleListParamsDirectionDesc PageRuleListParamsDirection = "desc"` - `Match param.Field[PageRuleListParamsMatch]` Query param: When set to `all`, all the search requirements must match. When set to `any`, only one of the search requirements has to match. - `const PageRuleListParamsMatchAny PageRuleListParamsMatch = "any"` - `const PageRuleListParamsMatchAll PageRuleListParamsMatch = "all"` - `Order param.Field[PageRuleListParamsOrder]` Query param: The field used to sort returned Page Rules. - `const PageRuleListParamsOrderStatus PageRuleListParamsOrder = "status"` - `const PageRuleListParamsOrderPriority PageRuleListParamsOrder = "priority"` - `Status param.Field[PageRuleListParamsStatus]` Query param: The status of the Page Rule. - `const PageRuleListParamsStatusActive PageRuleListParamsStatus = "active"` - `const PageRuleListParamsStatusDisabled PageRuleListParamsStatus = "disabled"` ### Returns - `type PageRuleListResponseEnvelopeResult []PageRule` - `ID string` Identifier. - `Actions []PageRuleAction` The set of actions to perform if the targets of this rule match the request. Actions can redirect to another URL or override settings, but not both. - `type AlwaysUseHTTPS struct{…}` - `ID AlwaysUseHTTPSID` If enabled, any `http://`` URL is converted to`https://` through a 301 redirect. - `const AlwaysUseHTTPSIDAlwaysUseHTTPS AlwaysUseHTTPSID = "always_use_https"` - `type AutomaticHTTPSRewrites struct{…}` - `ID AutomaticHTTPSRewritesID` Turn on or off Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesIDAutomaticHTTPSRewrites AutomaticHTTPSRewritesID = "automatic_https_rewrites"` - `Value AutomaticHTTPSRewritesValue` The status of Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesValueOn AutomaticHTTPSRewritesValue = "on"` - `const AutomaticHTTPSRewritesValueOff AutomaticHTTPSRewritesValue = "off"` - `type BrowserCacheTTL struct{…}` - `ID BrowserCacheTTLID` Control how long resources cached by client browsers remain valid. - `const BrowserCacheTTLIDBrowserCacheTTL BrowserCacheTTLID = "browser_cache_ttl"` - `Value int64` The number of seconds to cache resources for. Setting this to 0 enables "Respect Existing Headers". - `type BrowserCheck struct{…}` - `ID BrowserCheckID` Inspect the visitor's browser for headers commonly associated with spammers and certain bots. - `const BrowserCheckIDBrowserCheck BrowserCheckID = "browser_check"` - `Value BrowserCheckValue` The status of Browser Integrity Check. - `const BrowserCheckValueOn BrowserCheckValue = "on"` - `const BrowserCheckValueOff BrowserCheckValue = "off"` - `type PageRuleActionsBypassCacheOnCookie struct{…}` - `ID PageRuleActionsBypassCacheOnCookieID` Bypass cache and fetch resources from the origin server if a regular expression matches against a cookie name present in the request. - `const PageRuleActionsBypassCacheOnCookieIDBypassCacheOnCookie PageRuleActionsBypassCacheOnCookieID = "bypass_cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. Refer to [Bypass Cache on Cookie setting](https://developers.cloudflare.com/rules/page-rules/reference/additional-reference/#bypass-cache-on-cookie-setting) to learn about limited regular expression support. - `type PageRuleActionsCacheByDeviceType struct{…}` - `ID PageRuleActionsCacheByDeviceTypeID` Separate cached content based on the visitor's device type. - `const PageRuleActionsCacheByDeviceTypeIDCacheByDeviceType PageRuleActionsCacheByDeviceTypeID = "cache_by_device_type"` - `Value PageRuleActionsCacheByDeviceTypeValue` The status of Cache By Device Type. - `const PageRuleActionsCacheByDeviceTypeValueOn PageRuleActionsCacheByDeviceTypeValue = "on"` - `const PageRuleActionsCacheByDeviceTypeValueOff PageRuleActionsCacheByDeviceTypeValue = "off"` - `type PageRuleActionsCacheDeceptionArmor struct{…}` - `ID PageRuleActionsCacheDeceptionArmorID` Protect from web cache deception attacks while still allowing static assets to be cached. This setting verifies that the URL's extension matches the returned `Content-Type`. - `const PageRuleActionsCacheDeceptionArmorIDCacheDeceptionArmor PageRuleActionsCacheDeceptionArmorID = "cache_deception_armor"` - `Value PageRuleActionsCacheDeceptionArmorValue` The status of Cache Deception Armor. - `const PageRuleActionsCacheDeceptionArmorValueOn PageRuleActionsCacheDeceptionArmorValue = "on"` - `const PageRuleActionsCacheDeceptionArmorValueOff PageRuleActionsCacheDeceptionArmorValue = "off"` - `type PageRuleActionsCacheKeyFields struct{…}` - `ID PageRuleActionsCacheKeyFieldsID` Control specifically what variables to include when deciding which resources to cache. This allows customers to determine what to cache based on something other than just the URL. - `const PageRuleActionsCacheKeyFieldsIDCacheKeyFields PageRuleActionsCacheKeyFieldsID = "cache_key_fields"` - `Value PageRuleActionsCacheKeyFieldsValue` - `Cookie PageRuleActionsCacheKeyFieldsValueCookie` Controls which cookies appear in the Cache Key. - `CheckPresence []string` A list of cookies to check for the presence of, without including their actual values. - `Include []string` A list of cookies to include. - `Header PageRuleActionsCacheKeyFieldsValueHeader` Controls which headers go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `CheckPresence []string` A list of headers to check for the presence of, without including their actual values. - `Exclude []string` A list of headers to ignore. - `Include []string` A list of headers to include. - `Host PageRuleActionsCacheKeyFieldsValueHost` Determines which host header to include in the Cache Key. - `Resolved bool` Whether to include the Host header in the HTTP request sent to the origin. - `QueryString PageRuleActionsCacheKeyFieldsValueQueryString` Controls which URL query string parameters go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `Exclude PageRuleActionsCacheKeyFieldsValueQueryStringExcludeUnion` Ignore all query string parameters. - `type PageRuleActionsCacheKeyFieldsValueQueryStringExcludeString string` Ignore all query string parameters. - `const PageRuleActionsCacheKeyFieldsValueQueryStringExcludeStringStar PageRuleActionsCacheKeyFieldsValueQueryStringExcludeString = "*"` - `type PageRuleActionsCacheKeyFieldsValueQueryStringExcludeArray []string` A list of query string parameters to ignore. - `Include PageRuleActionsCacheKeyFieldsValueQueryStringIncludeUnion` Include all query string parameters. - `type PageRuleActionsCacheKeyFieldsValueQueryStringIncludeString string` Include all query string parameters. - `const PageRuleActionsCacheKeyFieldsValueQueryStringIncludeStringStar PageRuleActionsCacheKeyFieldsValueQueryStringIncludeString = "*"` - `type PageRuleActionsCacheKeyFieldsValueQueryStringIncludeArray []string` A list of query string parameters to include. - `User PageRuleActionsCacheKeyFieldsValueUser` Feature fields to add features about the end-user (client) into the Cache Key. - `DeviceType bool` Classifies a request as `mobile`, `desktop`, or `tablet` based on the User Agent. - `Geo bool` Includes the client's country, derived from the IP address. - `Lang bool` Includes the first language code contained in the `Accept-Language` header sent by the client. - `type CacheLevel struct{…}` - `ID CacheLevelID` Apply custom caching based on the option selected. - `const CacheLevelIDCacheLevel CacheLevelID = "cache_level"` - `Value CacheLevelValue` * `bypass`: Cloudflare does not cache. * `basic`: Delivers resources from cache when there is no query string. * `simplified`: Delivers the same resource to everyone independent of the query string. * `aggressive`: Caches all static content that has a query string. * `cache_everything`: Treats all content as static and caches all file types beyond the [Cloudflare default cached content](https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#default-cached-file-extensions). - `const CacheLevelValueBypass CacheLevelValue = "bypass"` - `const CacheLevelValueBasic CacheLevelValue = "basic"` - `const CacheLevelValueSimplified CacheLevelValue = "simplified"` - `const CacheLevelValueAggressive CacheLevelValue = "aggressive"` - `const CacheLevelValueCacheEverything CacheLevelValue = "cache_everything"` - `type PageRuleActionsCacheOnCookie struct{…}` - `ID PageRuleActionsCacheOnCookieID` Apply the Cache Everything option (Cache Level setting) based on a regular expression match against a cookie name. - `const PageRuleActionsCacheOnCookieIDCacheOnCookie PageRuleActionsCacheOnCookieID = "cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. - `type PageRuleActionsCacheTTLByStatus struct{…}` - `ID PageRuleActionsCacheTTLByStatusID` Enterprise customers can set cache time-to-live (TTL) based on the response status from the origin web server. Cache TTL refers to the duration of a resource in the Cloudflare network before being marked as stale or discarded from cache. Status codes are returned by a resource's origin. Setting cache TTL based on response status overrides the default cache behavior (standard caching) for static files and overrides cache instructions sent by the origin web server. To cache non-static assets, set a Cache Level of Cache Everything using a Page Rule. Setting no-store Cache-Control or a low TTL (using `max-age`/`s-maxage`) increases requests to origin web servers and decreases performance. - `const PageRuleActionsCacheTTLByStatusIDCacheTTLByStatus PageRuleActionsCacheTTLByStatusID = "cache_ttl_by_status"` - `Value map[string, PageRuleActionsCacheTTLByStatusValueUnion]` A JSON object containing status codes and their corresponding TTLs. Each key-value pair in the cache TTL by status cache rule has the following syntax - `status_code`: An integer value such as 200 or 500. status_code matches the exact status code from the origin web server. Valid status codes are between 100-999. - `status_code_range`: Integer values for from and to. status_code_range matches any status code from the origin web server within the specified range. - `value`: An integer value that defines the duration an asset is valid in seconds or one of the following strings: no-store (equivalent to -1), no-cache (equivalent to 0). - `type PageRuleActionsCacheTTLByStatusValueString string` `no-store` (equivalent to -1), `no-cache` (equivalent to 0) - `const PageRuleActionsCacheTTLByStatusValueStringNoCache PageRuleActionsCacheTTLByStatusValueString = "no-cache"` - `const PageRuleActionsCacheTTLByStatusValueStringNoStore PageRuleActionsCacheTTLByStatusValueString = "no-store"` - `UnionInt` - `type PageRuleActionsDisableApps struct{…}` - `ID PageRuleActionsDisableAppsID` Turn off all active [Cloudflare Apps](https://developers.cloudflare.com/support/more-dashboard-apps/cloudflare-apps/) (deprecated). - `const PageRuleActionsDisableAppsIDDisableApps PageRuleActionsDisableAppsID = "disable_apps"` - `type PageRuleActionsDisablePerformance struct{…}` - `ID PageRuleActionsDisablePerformanceID` Turn off [Rocket Loader](https://developers.cloudflare.com/speed/optimization/content/rocket-loader/), and [Polish](https://developers.cloudflare.com/images/polish/). - `const PageRuleActionsDisablePerformanceIDDisablePerformance PageRuleActionsDisablePerformanceID = "disable_performance"` - `type PageRuleActionsDisableSecurity struct{…}` - `ID PageRuleActionsDisableSecurityID` Turn off [Email Obfuscation](https://developers.cloudflare.com/waf/tools/scrape-shield/email-address-obfuscation/), [Rate Limiting (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/), [Scrape Shield](https://developers.cloudflare.com/waf/tools/scrape-shield/), [URL (Zone) Lockdown](https://developers.cloudflare.com/waf/tools/zone-lockdown/), and [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). - `const PageRuleActionsDisableSecurityIDDisableSecurity PageRuleActionsDisableSecurityID = "disable_security"` - `type PageRuleActionsDisableZaraz struct{…}` - `ID PageRuleActionsDisableZarazID` Turn off [Zaraz](https://developers.cloudflare.com/zaraz/). - `const PageRuleActionsDisableZarazIDDisableZaraz PageRuleActionsDisableZarazID = "disable_zaraz"` - `type PageRuleActionsEdgeCacheTTL struct{…}` - `ID PageRuleActionsEdgeCacheTTLID` Specify how long to cache a resource in the Cloudflare global network. *Edge Cache TTL* is not visible in response headers. - `const PageRuleActionsEdgeCacheTTLIDEdgeCacheTTL PageRuleActionsEdgeCacheTTLID = "edge_cache_ttl"` - `Value int64` - `type EmailObfuscation struct{…}` - `ID EmailObfuscationID` Turn on or off **Email Obfuscation**. - `const EmailObfuscationIDEmailObfuscation EmailObfuscationID = "email_obfuscation"` - `Value EmailObfuscationValue` The status of Email Obfuscation. - `const EmailObfuscationValueOn EmailObfuscationValue = "on"` - `const EmailObfuscationValueOff EmailObfuscationValue = "off"` - `type PageRuleActionsExplicitCacheControl struct{…}` - `ID PageRuleActionsExplicitCacheControlID` Origin Cache Control is enabled by default for Free, Pro, and Business domains and disabled by default for Enterprise domains. - `const PageRuleActionsExplicitCacheControlIDExplicitCacheControl PageRuleActionsExplicitCacheControlID = "explicit_cache_control"` - `Value PageRuleActionsExplicitCacheControlValue` The status of Origin Cache Control. - `const PageRuleActionsExplicitCacheControlValueOn PageRuleActionsExplicitCacheControlValue = "on"` - `const PageRuleActionsExplicitCacheControlValueOff PageRuleActionsExplicitCacheControlValue = "off"` - `type PageRuleActionsForwardingURL struct{…}` - `ID PageRuleActionsForwardingURLID` Redirects one URL to another using an `HTTP 301/302` redirect. Refer to [Wildcard matching and referencing](https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/). - `const PageRuleActionsForwardingURLIDForwardingURL PageRuleActionsForwardingURLID = "forwarding_url"` - `Value PageRuleActionsForwardingURLValue` - `StatusCode PageRuleActionsForwardingURLValueStatusCode` The status code to use for the URL redirect. 301 is a permanent redirect. 302 is a temporary redirect. - `const PageRuleActionsForwardingURLValueStatusCode301 PageRuleActionsForwardingURLValueStatusCode = 301` - `const PageRuleActionsForwardingURLValueStatusCode302 PageRuleActionsForwardingURLValueStatusCode = 302` - `URL string` The URL to redirect the request to. Notes: ${num} refers to the position of '*' in the constraint value. - `type PageRuleActionsHostHeaderOverride struct{…}` - `ID PageRuleActionsHostHeaderOverrideID` Apply a specific host header. - `const PageRuleActionsHostHeaderOverrideIDHostHeaderOverride PageRuleActionsHostHeaderOverrideID = "host_header_override"` - `Value string` The hostname to use in the `Host` header - `type IPGeolocation struct{…}` - `ID IPGeolocationID` Cloudflare adds a CF-IPCountry HTTP header containing the country code that corresponds to the visitor. - `const IPGeolocationIDIPGeolocation IPGeolocationID = "ip_geolocation"` - `Value IPGeolocationValue` The status of adding the IP Geolocation Header. - `const IPGeolocationValueOn IPGeolocationValue = "on"` - `const IPGeolocationValueOff IPGeolocationValue = "off"` - `type Mirage struct{…}` - `ID MirageID` Cloudflare Mirage reduces bandwidth used by images in mobile browsers. It can accelerate loading of image-heavy websites on very slow mobile connections and HTTP/1. - `const MirageIDMirage MirageID = "mirage"` - `Value MirageValue` The status of Mirage. - `const MirageValueOn MirageValue = "on"` - `const MirageValueOff MirageValue = "off"` - `type OpportunisticEncryption struct{…}` - `ID OpportunisticEncryptionID` Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted TLS channel. It's not a substitute for HTTPS, but provides additional security for otherwise vulnerable requests. - `const OpportunisticEncryptionIDOpportunisticEncryption OpportunisticEncryptionID = "opportunistic_encryption"` - `Value OpportunisticEncryptionValue` The status of Opportunistic Encryption. - `const OpportunisticEncryptionValueOn OpportunisticEncryptionValue = "on"` - `const OpportunisticEncryptionValueOff OpportunisticEncryptionValue = "off"` - `type OriginErrorPagePassThru struct{…}` - `ID OriginErrorPagePassThruID` Turn on or off Cloudflare error pages generated from issues sent from the origin server. If enabled, this setting triggers error pages issued by the origin. - `const OriginErrorPagePassThruIDOriginErrorPagePassThru OriginErrorPagePassThruID = "origin_error_page_pass_thru"` - `Value OriginErrorPagePassThruValue` The status of Origin Error Page Passthru. - `const OriginErrorPagePassThruValueOn OriginErrorPagePassThruValue = "on"` - `const OriginErrorPagePassThruValueOff OriginErrorPagePassThruValue = "off"` - `type Polish struct{…}` - `ID PolishID` Apply options from the Polish feature of the Cloudflare Speed app. - `const PolishIDPolish PolishID = "polish"` - `Value PolishValue` The level of Polish you want applied to your origin. - `const PolishValueOff PolishValue = "off"` - `const PolishValueLossless PolishValue = "lossless"` - `const PolishValueLossy PolishValue = "lossy"` - `type PageRuleActionsResolveOverride struct{…}` - `ID PageRuleActionsResolveOverrideID` Change the origin address to the value specified in this setting. - `const PageRuleActionsResolveOverrideIDResolveOverride PageRuleActionsResolveOverrideID = "resolve_override"` - `Value string` The origin address you want to override with. - `type PageRuleActionsRespectStrongEtag struct{…}` - `ID PageRuleActionsRespectStrongEtagID` Turn on or off byte-for-byte equivalency checks between the Cloudflare cache and the origin server. - `const PageRuleActionsRespectStrongEtagIDRespectStrongEtag PageRuleActionsRespectStrongEtagID = "respect_strong_etag"` - `Value PageRuleActionsRespectStrongEtagValue` The status of Respect Strong ETags - `const PageRuleActionsRespectStrongEtagValueOn PageRuleActionsRespectStrongEtagValue = "on"` - `const PageRuleActionsRespectStrongEtagValueOff PageRuleActionsRespectStrongEtagValue = "off"` - `type ResponseBuffering struct{…}` - `ID ResponseBufferingID` Turn on or off whether Cloudflare should wait for an entire file from the origin server before forwarding it to the site visitor. By default, Cloudflare sends packets to the client as they arrive from the origin server. - `const ResponseBufferingIDResponseBuffering ResponseBufferingID = "response_buffering"` - `Value ResponseBufferingValue` The status of Response Buffering - `const ResponseBufferingValueOn ResponseBufferingValue = "on"` - `const ResponseBufferingValueOff ResponseBufferingValue = "off"` - `type RocketLoader struct{…}` - `ID RocketLoaderID` Turn on or off Rocket Loader in the Cloudflare Speed app. - `const RocketLoaderIDRocketLoader RocketLoaderID = "rocket_loader"` - `Value RocketLoaderValue` The status of Rocket Loader - `const RocketLoaderValueOn RocketLoaderValue = "on"` - `const RocketLoaderValueOff RocketLoaderValue = "off"` - `type SecurityLevel struct{…}` - `ID SecurityLevelID` Control options for the **Security Level** feature from the **Security** app. - `const SecurityLevelIDSecurityLevel SecurityLevelID = "security_level"` - `Value SecurityLevelValue` - `const SecurityLevelValueOff SecurityLevelValue = "off"` - `const SecurityLevelValueEssentiallyOff SecurityLevelValue = "essentially_off"` - `const SecurityLevelValueLow SecurityLevelValue = "low"` - `const SecurityLevelValueMedium SecurityLevelValue = "medium"` - `const SecurityLevelValueHigh SecurityLevelValue = "high"` - `const SecurityLevelValueUnderAttack SecurityLevelValue = "under_attack"` - `type SortQueryStringForCache struct{…}` - `ID SortQueryStringForCacheID` Turn on or off the reordering of query strings. When query strings have the same structure, caching improves. - `const SortQueryStringForCacheIDSortQueryStringForCache SortQueryStringForCacheID = "sort_query_string_for_cache"` - `Value SortQueryStringForCacheValue` The status of Query String Sort - `const SortQueryStringForCacheValueOn SortQueryStringForCacheValue = "on"` - `const SortQueryStringForCacheValueOff SortQueryStringForCacheValue = "off"` - `type SSL struct{…}` - `ID SSLID` Control options for the SSL feature of the Edge Certificates tab in the Cloudflare SSL/TLS app. - `const SSLIDSSL SSLID = "ssl"` - `Value SSLValue` The encryption mode that Cloudflare uses to connect to your origin server. - `const SSLValueOff SSLValue = "off"` - `const SSLValueFlexible SSLValue = "flexible"` - `const SSLValueFull SSLValue = "full"` - `const SSLValueStrict SSLValue = "strict"` - `const SSLValueOriginPull SSLValue = "origin_pull"` - `type TrueClientIPHeader struct{…}` - `ID TrueClientIPHeaderID` Turn on or off the True-Client-IP Header feature of the Cloudflare Network app. - `const TrueClientIPHeaderIDTrueClientIPHeader TrueClientIPHeaderID = "true_client_ip_header"` - `Value TrueClientIPHeaderValue` The status of True Client IP Header. - `const TrueClientIPHeaderValueOn TrueClientIPHeaderValue = "on"` - `const TrueClientIPHeaderValueOff TrueClientIPHeaderValue = "off"` - `type WAF struct{…}` - `ID WAFID` Turn on or off [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). You cannot enable or disable individual WAF managed rules via Page Rules. - `const WAFIDWAF WAFID = "waf"` - `Value WAFValue` The status of WAF managed rules (previous version). - `const WAFValueOn WAFValue = "on"` - `const WAFValueOff WAFValue = "off"` - `CreatedOn Time` The timestamp of when the Page Rule was created. - `ModifiedOn Time` The timestamp of when the Page Rule was last modified. - `Priority int64` The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: `/images/*`) but want a more specific Page Rule to take precedence (rule B: `/images/special/*`), specify a higher priority for rule B so it overrides rule A. - `Status PageRuleStatus` The status of the Page Rule. - `const PageRuleStatusActive PageRuleStatus = "active"` - `const PageRuleStatusDisabled PageRuleStatus = "disabled"` - `Targets []Target` The rule targets to evaluate on each request. - `Constraint TargetConstraint` String constraint. - `Operator TargetConstraintOperator` The matches operator can use asterisks and pipes as wildcard and 'or' operators. - `const TargetConstraintOperatorMatches TargetConstraintOperator = "matches"` - `const TargetConstraintOperatorContains TargetConstraintOperator = "contains"` - `const TargetConstraintOperatorEquals TargetConstraintOperator = "equals"` - `const TargetConstraintOperatorNotEqual TargetConstraintOperator = "not_equal"` - `const TargetConstraintOperatorNotContain TargetConstraintOperator = "not_contain"` - `Value string` The URL pattern to match against the current request. The pattern may contain up to four asterisks ('*') as placeholders. - `Target TargetTarget` A target based on the URL of the request. - `const TargetTargetURL TargetTarget = "url"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/page_rules" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) pageRules, err := client.PageRules.List(context.TODO(), page_rules.PageRuleListParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", pageRules) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": [ { "id": "023e105f4ecef8ad9ca31a8372d0c353", "actions": [ { "id": "browser_check", "value": "on" } ], "created_on": "2014-01-01T05:20:00.12345Z", "modified_on": "2014-01-01T05:20:00.12345Z", "priority": 0, "status": "active", "targets": [ { "constraint": { "operator": "matches", "value": "*example.com/images/*" }, "target": "url" } ] } ] } ``` ## Get a Page Rule `client.PageRules.Get(ctx, pageruleID, query) (*PageRule, error)` **get** `/zones/{zone_id}/pagerules/{pagerule_id}` Fetches the details of a Page Rule. ### Parameters - `pageruleID string` Identifier. - `query PageRuleGetParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type PageRule struct{…}` - `ID string` Identifier. - `Actions []PageRuleAction` The set of actions to perform if the targets of this rule match the request. Actions can redirect to another URL or override settings, but not both. - `type AlwaysUseHTTPS struct{…}` - `ID AlwaysUseHTTPSID` If enabled, any `http://`` URL is converted to`https://` through a 301 redirect. - `const AlwaysUseHTTPSIDAlwaysUseHTTPS AlwaysUseHTTPSID = "always_use_https"` - `type AutomaticHTTPSRewrites struct{…}` - `ID AutomaticHTTPSRewritesID` Turn on or off Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesIDAutomaticHTTPSRewrites AutomaticHTTPSRewritesID = "automatic_https_rewrites"` - `Value AutomaticHTTPSRewritesValue` The status of Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesValueOn AutomaticHTTPSRewritesValue = "on"` - `const AutomaticHTTPSRewritesValueOff AutomaticHTTPSRewritesValue = "off"` - `type BrowserCacheTTL struct{…}` - `ID BrowserCacheTTLID` Control how long resources cached by client browsers remain valid. - `const BrowserCacheTTLIDBrowserCacheTTL BrowserCacheTTLID = "browser_cache_ttl"` - `Value int64` The number of seconds to cache resources for. Setting this to 0 enables "Respect Existing Headers". - `type BrowserCheck struct{…}` - `ID BrowserCheckID` Inspect the visitor's browser for headers commonly associated with spammers and certain bots. - `const BrowserCheckIDBrowserCheck BrowserCheckID = "browser_check"` - `Value BrowserCheckValue` The status of Browser Integrity Check. - `const BrowserCheckValueOn BrowserCheckValue = "on"` - `const BrowserCheckValueOff BrowserCheckValue = "off"` - `type PageRuleActionsBypassCacheOnCookie struct{…}` - `ID PageRuleActionsBypassCacheOnCookieID` Bypass cache and fetch resources from the origin server if a regular expression matches against a cookie name present in the request. - `const PageRuleActionsBypassCacheOnCookieIDBypassCacheOnCookie PageRuleActionsBypassCacheOnCookieID = "bypass_cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. Refer to [Bypass Cache on Cookie setting](https://developers.cloudflare.com/rules/page-rules/reference/additional-reference/#bypass-cache-on-cookie-setting) to learn about limited regular expression support. - `type PageRuleActionsCacheByDeviceType struct{…}` - `ID PageRuleActionsCacheByDeviceTypeID` Separate cached content based on the visitor's device type. - `const PageRuleActionsCacheByDeviceTypeIDCacheByDeviceType PageRuleActionsCacheByDeviceTypeID = "cache_by_device_type"` - `Value PageRuleActionsCacheByDeviceTypeValue` The status of Cache By Device Type. - `const PageRuleActionsCacheByDeviceTypeValueOn PageRuleActionsCacheByDeviceTypeValue = "on"` - `const PageRuleActionsCacheByDeviceTypeValueOff PageRuleActionsCacheByDeviceTypeValue = "off"` - `type PageRuleActionsCacheDeceptionArmor struct{…}` - `ID PageRuleActionsCacheDeceptionArmorID` Protect from web cache deception attacks while still allowing static assets to be cached. This setting verifies that the URL's extension matches the returned `Content-Type`. - `const PageRuleActionsCacheDeceptionArmorIDCacheDeceptionArmor PageRuleActionsCacheDeceptionArmorID = "cache_deception_armor"` - `Value PageRuleActionsCacheDeceptionArmorValue` The status of Cache Deception Armor. - `const PageRuleActionsCacheDeceptionArmorValueOn PageRuleActionsCacheDeceptionArmorValue = "on"` - `const PageRuleActionsCacheDeceptionArmorValueOff PageRuleActionsCacheDeceptionArmorValue = "off"` - `type PageRuleActionsCacheKeyFields struct{…}` - `ID PageRuleActionsCacheKeyFieldsID` Control specifically what variables to include when deciding which resources to cache. This allows customers to determine what to cache based on something other than just the URL. - `const PageRuleActionsCacheKeyFieldsIDCacheKeyFields PageRuleActionsCacheKeyFieldsID = "cache_key_fields"` - `Value PageRuleActionsCacheKeyFieldsValue` - `Cookie PageRuleActionsCacheKeyFieldsValueCookie` Controls which cookies appear in the Cache Key. - `CheckPresence []string` A list of cookies to check for the presence of, without including their actual values. - `Include []string` A list of cookies to include. - `Header PageRuleActionsCacheKeyFieldsValueHeader` Controls which headers go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `CheckPresence []string` A list of headers to check for the presence of, without including their actual values. - `Exclude []string` A list of headers to ignore. - `Include []string` A list of headers to include. - `Host PageRuleActionsCacheKeyFieldsValueHost` Determines which host header to include in the Cache Key. - `Resolved bool` Whether to include the Host header in the HTTP request sent to the origin. - `QueryString PageRuleActionsCacheKeyFieldsValueQueryString` Controls which URL query string parameters go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `Exclude PageRuleActionsCacheKeyFieldsValueQueryStringExcludeUnion` Ignore all query string parameters. - `type PageRuleActionsCacheKeyFieldsValueQueryStringExcludeString string` Ignore all query string parameters. - `const PageRuleActionsCacheKeyFieldsValueQueryStringExcludeStringStar PageRuleActionsCacheKeyFieldsValueQueryStringExcludeString = "*"` - `type PageRuleActionsCacheKeyFieldsValueQueryStringExcludeArray []string` A list of query string parameters to ignore. - `Include PageRuleActionsCacheKeyFieldsValueQueryStringIncludeUnion` Include all query string parameters. - `type PageRuleActionsCacheKeyFieldsValueQueryStringIncludeString string` Include all query string parameters. - `const PageRuleActionsCacheKeyFieldsValueQueryStringIncludeStringStar PageRuleActionsCacheKeyFieldsValueQueryStringIncludeString = "*"` - `type PageRuleActionsCacheKeyFieldsValueQueryStringIncludeArray []string` A list of query string parameters to include. - `User PageRuleActionsCacheKeyFieldsValueUser` Feature fields to add features about the end-user (client) into the Cache Key. - `DeviceType bool` Classifies a request as `mobile`, `desktop`, or `tablet` based on the User Agent. - `Geo bool` Includes the client's country, derived from the IP address. - `Lang bool` Includes the first language code contained in the `Accept-Language` header sent by the client. - `type CacheLevel struct{…}` - `ID CacheLevelID` Apply custom caching based on the option selected. - `const CacheLevelIDCacheLevel CacheLevelID = "cache_level"` - `Value CacheLevelValue` * `bypass`: Cloudflare does not cache. * `basic`: Delivers resources from cache when there is no query string. * `simplified`: Delivers the same resource to everyone independent of the query string. * `aggressive`: Caches all static content that has a query string. * `cache_everything`: Treats all content as static and caches all file types beyond the [Cloudflare default cached content](https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#default-cached-file-extensions). - `const CacheLevelValueBypass CacheLevelValue = "bypass"` - `const CacheLevelValueBasic CacheLevelValue = "basic"` - `const CacheLevelValueSimplified CacheLevelValue = "simplified"` - `const CacheLevelValueAggressive CacheLevelValue = "aggressive"` - `const CacheLevelValueCacheEverything CacheLevelValue = "cache_everything"` - `type PageRuleActionsCacheOnCookie struct{…}` - `ID PageRuleActionsCacheOnCookieID` Apply the Cache Everything option (Cache Level setting) based on a regular expression match against a cookie name. - `const PageRuleActionsCacheOnCookieIDCacheOnCookie PageRuleActionsCacheOnCookieID = "cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. - `type PageRuleActionsCacheTTLByStatus struct{…}` - `ID PageRuleActionsCacheTTLByStatusID` Enterprise customers can set cache time-to-live (TTL) based on the response status from the origin web server. Cache TTL refers to the duration of a resource in the Cloudflare network before being marked as stale or discarded from cache. Status codes are returned by a resource's origin. Setting cache TTL based on response status overrides the default cache behavior (standard caching) for static files and overrides cache instructions sent by the origin web server. To cache non-static assets, set a Cache Level of Cache Everything using a Page Rule. Setting no-store Cache-Control or a low TTL (using `max-age`/`s-maxage`) increases requests to origin web servers and decreases performance. - `const PageRuleActionsCacheTTLByStatusIDCacheTTLByStatus PageRuleActionsCacheTTLByStatusID = "cache_ttl_by_status"` - `Value map[string, PageRuleActionsCacheTTLByStatusValueUnion]` A JSON object containing status codes and their corresponding TTLs. Each key-value pair in the cache TTL by status cache rule has the following syntax - `status_code`: An integer value such as 200 or 500. status_code matches the exact status code from the origin web server. Valid status codes are between 100-999. - `status_code_range`: Integer values for from and to. status_code_range matches any status code from the origin web server within the specified range. - `value`: An integer value that defines the duration an asset is valid in seconds or one of the following strings: no-store (equivalent to -1), no-cache (equivalent to 0). - `type PageRuleActionsCacheTTLByStatusValueString string` `no-store` (equivalent to -1), `no-cache` (equivalent to 0) - `const PageRuleActionsCacheTTLByStatusValueStringNoCache PageRuleActionsCacheTTLByStatusValueString = "no-cache"` - `const PageRuleActionsCacheTTLByStatusValueStringNoStore PageRuleActionsCacheTTLByStatusValueString = "no-store"` - `UnionInt` - `type PageRuleActionsDisableApps struct{…}` - `ID PageRuleActionsDisableAppsID` Turn off all active [Cloudflare Apps](https://developers.cloudflare.com/support/more-dashboard-apps/cloudflare-apps/) (deprecated). - `const PageRuleActionsDisableAppsIDDisableApps PageRuleActionsDisableAppsID = "disable_apps"` - `type PageRuleActionsDisablePerformance struct{…}` - `ID PageRuleActionsDisablePerformanceID` Turn off [Rocket Loader](https://developers.cloudflare.com/speed/optimization/content/rocket-loader/), and [Polish](https://developers.cloudflare.com/images/polish/). - `const PageRuleActionsDisablePerformanceIDDisablePerformance PageRuleActionsDisablePerformanceID = "disable_performance"` - `type PageRuleActionsDisableSecurity struct{…}` - `ID PageRuleActionsDisableSecurityID` Turn off [Email Obfuscation](https://developers.cloudflare.com/waf/tools/scrape-shield/email-address-obfuscation/), [Rate Limiting (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/), [Scrape Shield](https://developers.cloudflare.com/waf/tools/scrape-shield/), [URL (Zone) Lockdown](https://developers.cloudflare.com/waf/tools/zone-lockdown/), and [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). - `const PageRuleActionsDisableSecurityIDDisableSecurity PageRuleActionsDisableSecurityID = "disable_security"` - `type PageRuleActionsDisableZaraz struct{…}` - `ID PageRuleActionsDisableZarazID` Turn off [Zaraz](https://developers.cloudflare.com/zaraz/). - `const PageRuleActionsDisableZarazIDDisableZaraz PageRuleActionsDisableZarazID = "disable_zaraz"` - `type PageRuleActionsEdgeCacheTTL struct{…}` - `ID PageRuleActionsEdgeCacheTTLID` Specify how long to cache a resource in the Cloudflare global network. *Edge Cache TTL* is not visible in response headers. - `const PageRuleActionsEdgeCacheTTLIDEdgeCacheTTL PageRuleActionsEdgeCacheTTLID = "edge_cache_ttl"` - `Value int64` - `type EmailObfuscation struct{…}` - `ID EmailObfuscationID` Turn on or off **Email Obfuscation**. - `const EmailObfuscationIDEmailObfuscation EmailObfuscationID = "email_obfuscation"` - `Value EmailObfuscationValue` The status of Email Obfuscation. - `const EmailObfuscationValueOn EmailObfuscationValue = "on"` - `const EmailObfuscationValueOff EmailObfuscationValue = "off"` - `type PageRuleActionsExplicitCacheControl struct{…}` - `ID PageRuleActionsExplicitCacheControlID` Origin Cache Control is enabled by default for Free, Pro, and Business domains and disabled by default for Enterprise domains. - `const PageRuleActionsExplicitCacheControlIDExplicitCacheControl PageRuleActionsExplicitCacheControlID = "explicit_cache_control"` - `Value PageRuleActionsExplicitCacheControlValue` The status of Origin Cache Control. - `const PageRuleActionsExplicitCacheControlValueOn PageRuleActionsExplicitCacheControlValue = "on"` - `const PageRuleActionsExplicitCacheControlValueOff PageRuleActionsExplicitCacheControlValue = "off"` - `type PageRuleActionsForwardingURL struct{…}` - `ID PageRuleActionsForwardingURLID` Redirects one URL to another using an `HTTP 301/302` redirect. Refer to [Wildcard matching and referencing](https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/). - `const PageRuleActionsForwardingURLIDForwardingURL PageRuleActionsForwardingURLID = "forwarding_url"` - `Value PageRuleActionsForwardingURLValue` - `StatusCode PageRuleActionsForwardingURLValueStatusCode` The status code to use for the URL redirect. 301 is a permanent redirect. 302 is a temporary redirect. - `const PageRuleActionsForwardingURLValueStatusCode301 PageRuleActionsForwardingURLValueStatusCode = 301` - `const PageRuleActionsForwardingURLValueStatusCode302 PageRuleActionsForwardingURLValueStatusCode = 302` - `URL string` The URL to redirect the request to. Notes: ${num} refers to the position of '*' in the constraint value. - `type PageRuleActionsHostHeaderOverride struct{…}` - `ID PageRuleActionsHostHeaderOverrideID` Apply a specific host header. - `const PageRuleActionsHostHeaderOverrideIDHostHeaderOverride PageRuleActionsHostHeaderOverrideID = "host_header_override"` - `Value string` The hostname to use in the `Host` header - `type IPGeolocation struct{…}` - `ID IPGeolocationID` Cloudflare adds a CF-IPCountry HTTP header containing the country code that corresponds to the visitor. - `const IPGeolocationIDIPGeolocation IPGeolocationID = "ip_geolocation"` - `Value IPGeolocationValue` The status of adding the IP Geolocation Header. - `const IPGeolocationValueOn IPGeolocationValue = "on"` - `const IPGeolocationValueOff IPGeolocationValue = "off"` - `type Mirage struct{…}` - `ID MirageID` Cloudflare Mirage reduces bandwidth used by images in mobile browsers. It can accelerate loading of image-heavy websites on very slow mobile connections and HTTP/1. - `const MirageIDMirage MirageID = "mirage"` - `Value MirageValue` The status of Mirage. - `const MirageValueOn MirageValue = "on"` - `const MirageValueOff MirageValue = "off"` - `type OpportunisticEncryption struct{…}` - `ID OpportunisticEncryptionID` Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted TLS channel. It's not a substitute for HTTPS, but provides additional security for otherwise vulnerable requests. - `const OpportunisticEncryptionIDOpportunisticEncryption OpportunisticEncryptionID = "opportunistic_encryption"` - `Value OpportunisticEncryptionValue` The status of Opportunistic Encryption. - `const OpportunisticEncryptionValueOn OpportunisticEncryptionValue = "on"` - `const OpportunisticEncryptionValueOff OpportunisticEncryptionValue = "off"` - `type OriginErrorPagePassThru struct{…}` - `ID OriginErrorPagePassThruID` Turn on or off Cloudflare error pages generated from issues sent from the origin server. If enabled, this setting triggers error pages issued by the origin. - `const OriginErrorPagePassThruIDOriginErrorPagePassThru OriginErrorPagePassThruID = "origin_error_page_pass_thru"` - `Value OriginErrorPagePassThruValue` The status of Origin Error Page Passthru. - `const OriginErrorPagePassThruValueOn OriginErrorPagePassThruValue = "on"` - `const OriginErrorPagePassThruValueOff OriginErrorPagePassThruValue = "off"` - `type Polish struct{…}` - `ID PolishID` Apply options from the Polish feature of the Cloudflare Speed app. - `const PolishIDPolish PolishID = "polish"` - `Value PolishValue` The level of Polish you want applied to your origin. - `const PolishValueOff PolishValue = "off"` - `const PolishValueLossless PolishValue = "lossless"` - `const PolishValueLossy PolishValue = "lossy"` - `type PageRuleActionsResolveOverride struct{…}` - `ID PageRuleActionsResolveOverrideID` Change the origin address to the value specified in this setting. - `const PageRuleActionsResolveOverrideIDResolveOverride PageRuleActionsResolveOverrideID = "resolve_override"` - `Value string` The origin address you want to override with. - `type PageRuleActionsRespectStrongEtag struct{…}` - `ID PageRuleActionsRespectStrongEtagID` Turn on or off byte-for-byte equivalency checks between the Cloudflare cache and the origin server. - `const PageRuleActionsRespectStrongEtagIDRespectStrongEtag PageRuleActionsRespectStrongEtagID = "respect_strong_etag"` - `Value PageRuleActionsRespectStrongEtagValue` The status of Respect Strong ETags - `const PageRuleActionsRespectStrongEtagValueOn PageRuleActionsRespectStrongEtagValue = "on"` - `const PageRuleActionsRespectStrongEtagValueOff PageRuleActionsRespectStrongEtagValue = "off"` - `type ResponseBuffering struct{…}` - `ID ResponseBufferingID` Turn on or off whether Cloudflare should wait for an entire file from the origin server before forwarding it to the site visitor. By default, Cloudflare sends packets to the client as they arrive from the origin server. - `const ResponseBufferingIDResponseBuffering ResponseBufferingID = "response_buffering"` - `Value ResponseBufferingValue` The status of Response Buffering - `const ResponseBufferingValueOn ResponseBufferingValue = "on"` - `const ResponseBufferingValueOff ResponseBufferingValue = "off"` - `type RocketLoader struct{…}` - `ID RocketLoaderID` Turn on or off Rocket Loader in the Cloudflare Speed app. - `const RocketLoaderIDRocketLoader RocketLoaderID = "rocket_loader"` - `Value RocketLoaderValue` The status of Rocket Loader - `const RocketLoaderValueOn RocketLoaderValue = "on"` - `const RocketLoaderValueOff RocketLoaderValue = "off"` - `type SecurityLevel struct{…}` - `ID SecurityLevelID` Control options for the **Security Level** feature from the **Security** app. - `const SecurityLevelIDSecurityLevel SecurityLevelID = "security_level"` - `Value SecurityLevelValue` - `const SecurityLevelValueOff SecurityLevelValue = "off"` - `const SecurityLevelValueEssentiallyOff SecurityLevelValue = "essentially_off"` - `const SecurityLevelValueLow SecurityLevelValue = "low"` - `const SecurityLevelValueMedium SecurityLevelValue = "medium"` - `const SecurityLevelValueHigh SecurityLevelValue = "high"` - `const SecurityLevelValueUnderAttack SecurityLevelValue = "under_attack"` - `type SortQueryStringForCache struct{…}` - `ID SortQueryStringForCacheID` Turn on or off the reordering of query strings. When query strings have the same structure, caching improves. - `const SortQueryStringForCacheIDSortQueryStringForCache SortQueryStringForCacheID = "sort_query_string_for_cache"` - `Value SortQueryStringForCacheValue` The status of Query String Sort - `const SortQueryStringForCacheValueOn SortQueryStringForCacheValue = "on"` - `const SortQueryStringForCacheValueOff SortQueryStringForCacheValue = "off"` - `type SSL struct{…}` - `ID SSLID` Control options for the SSL feature of the Edge Certificates tab in the Cloudflare SSL/TLS app. - `const SSLIDSSL SSLID = "ssl"` - `Value SSLValue` The encryption mode that Cloudflare uses to connect to your origin server. - `const SSLValueOff SSLValue = "off"` - `const SSLValueFlexible SSLValue = "flexible"` - `const SSLValueFull SSLValue = "full"` - `const SSLValueStrict SSLValue = "strict"` - `const SSLValueOriginPull SSLValue = "origin_pull"` - `type TrueClientIPHeader struct{…}` - `ID TrueClientIPHeaderID` Turn on or off the True-Client-IP Header feature of the Cloudflare Network app. - `const TrueClientIPHeaderIDTrueClientIPHeader TrueClientIPHeaderID = "true_client_ip_header"` - `Value TrueClientIPHeaderValue` The status of True Client IP Header. - `const TrueClientIPHeaderValueOn TrueClientIPHeaderValue = "on"` - `const TrueClientIPHeaderValueOff TrueClientIPHeaderValue = "off"` - `type WAF struct{…}` - `ID WAFID` Turn on or off [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). You cannot enable or disable individual WAF managed rules via Page Rules. - `const WAFIDWAF WAFID = "waf"` - `Value WAFValue` The status of WAF managed rules (previous version). - `const WAFValueOn WAFValue = "on"` - `const WAFValueOff WAFValue = "off"` - `CreatedOn Time` The timestamp of when the Page Rule was created. - `ModifiedOn Time` The timestamp of when the Page Rule was last modified. - `Priority int64` The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: `/images/*`) but want a more specific Page Rule to take precedence (rule B: `/images/special/*`), specify a higher priority for rule B so it overrides rule A. - `Status PageRuleStatus` The status of the Page Rule. - `const PageRuleStatusActive PageRuleStatus = "active"` - `const PageRuleStatusDisabled PageRuleStatus = "disabled"` - `Targets []Target` The rule targets to evaluate on each request. - `Constraint TargetConstraint` String constraint. - `Operator TargetConstraintOperator` The matches operator can use asterisks and pipes as wildcard and 'or' operators. - `const TargetConstraintOperatorMatches TargetConstraintOperator = "matches"` - `const TargetConstraintOperatorContains TargetConstraintOperator = "contains"` - `const TargetConstraintOperatorEquals TargetConstraintOperator = "equals"` - `const TargetConstraintOperatorNotEqual TargetConstraintOperator = "not_equal"` - `const TargetConstraintOperatorNotContain TargetConstraintOperator = "not_contain"` - `Value string` The URL pattern to match against the current request. The pattern may contain up to four asterisks ('*') as placeholders. - `Target TargetTarget` A target based on the URL of the request. - `const TargetTargetURL TargetTarget = "url"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/page_rules" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) pageRule, err := client.PageRules.Get( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", page_rules.PageRuleGetParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", pageRule.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353", "actions": [ { "id": "browser_check", "value": "on" } ], "created_on": "2014-01-01T05:20:00.12345Z", "modified_on": "2014-01-01T05:20:00.12345Z", "priority": 0, "status": "active", "targets": [ { "constraint": { "operator": "matches", "value": "*example.com/images/*" }, "target": "url" } ] } } ``` ## Create a Page Rule `client.PageRules.New(ctx, params) (*PageRule, error)` **post** `/zones/{zone_id}/pagerules` Creates a new Page Rule. ### Parameters - `params PageRuleNewParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Actions param.Field[[]PageRuleNewParamsAction]` Body param: The set of actions to perform if the targets of this rule match the request. Actions can redirect to another URL or override settings, but not both. - `type AlwaysUseHTTPS struct{…}` - `ID AlwaysUseHTTPSID` If enabled, any `http://`` URL is converted to`https://` through a 301 redirect. - `const AlwaysUseHTTPSIDAlwaysUseHTTPS AlwaysUseHTTPSID = "always_use_https"` - `type AutomaticHTTPSRewrites struct{…}` - `ID AutomaticHTTPSRewritesID` Turn on or off Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesIDAutomaticHTTPSRewrites AutomaticHTTPSRewritesID = "automatic_https_rewrites"` - `Value AutomaticHTTPSRewritesValue` The status of Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesValueOn AutomaticHTTPSRewritesValue = "on"` - `const AutomaticHTTPSRewritesValueOff AutomaticHTTPSRewritesValue = "off"` - `type BrowserCacheTTL struct{…}` - `ID BrowserCacheTTLID` Control how long resources cached by client browsers remain valid. - `const BrowserCacheTTLIDBrowserCacheTTL BrowserCacheTTLID = "browser_cache_ttl"` - `Value int64` The number of seconds to cache resources for. Setting this to 0 enables "Respect Existing Headers". - `type BrowserCheck struct{…}` - `ID BrowserCheckID` Inspect the visitor's browser for headers commonly associated with spammers and certain bots. - `const BrowserCheckIDBrowserCheck BrowserCheckID = "browser_check"` - `Value BrowserCheckValue` The status of Browser Integrity Check. - `const BrowserCheckValueOn BrowserCheckValue = "on"` - `const BrowserCheckValueOff BrowserCheckValue = "off"` - `type PageRuleNewParamsActionsBypassCacheOnCookie struct{…}` - `ID PageRuleNewParamsActionsBypassCacheOnCookieID` Bypass cache and fetch resources from the origin server if a regular expression matches against a cookie name present in the request. - `const PageRuleNewParamsActionsBypassCacheOnCookieIDBypassCacheOnCookie PageRuleNewParamsActionsBypassCacheOnCookieID = "bypass_cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. Refer to [Bypass Cache on Cookie setting](https://developers.cloudflare.com/rules/page-rules/reference/additional-reference/#bypass-cache-on-cookie-setting) to learn about limited regular expression support. - `type PageRuleNewParamsActionsCacheByDeviceType struct{…}` - `ID PageRuleNewParamsActionsCacheByDeviceTypeID` Separate cached content based on the visitor's device type. - `const PageRuleNewParamsActionsCacheByDeviceTypeIDCacheByDeviceType PageRuleNewParamsActionsCacheByDeviceTypeID = "cache_by_device_type"` - `Value PageRuleNewParamsActionsCacheByDeviceTypeValue` The status of Cache By Device Type. - `const PageRuleNewParamsActionsCacheByDeviceTypeValueOn PageRuleNewParamsActionsCacheByDeviceTypeValue = "on"` - `const PageRuleNewParamsActionsCacheByDeviceTypeValueOff PageRuleNewParamsActionsCacheByDeviceTypeValue = "off"` - `type PageRuleNewParamsActionsCacheDeceptionArmor struct{…}` - `ID PageRuleNewParamsActionsCacheDeceptionArmorID` Protect from web cache deception attacks while still allowing static assets to be cached. This setting verifies that the URL's extension matches the returned `Content-Type`. - `const PageRuleNewParamsActionsCacheDeceptionArmorIDCacheDeceptionArmor PageRuleNewParamsActionsCacheDeceptionArmorID = "cache_deception_armor"` - `Value PageRuleNewParamsActionsCacheDeceptionArmorValue` The status of Cache Deception Armor. - `const PageRuleNewParamsActionsCacheDeceptionArmorValueOn PageRuleNewParamsActionsCacheDeceptionArmorValue = "on"` - `const PageRuleNewParamsActionsCacheDeceptionArmorValueOff PageRuleNewParamsActionsCacheDeceptionArmorValue = "off"` - `type PageRuleNewParamsActionsCacheKeyFields struct{…}` - `ID PageRuleNewParamsActionsCacheKeyFieldsID` Control specifically what variables to include when deciding which resources to cache. This allows customers to determine what to cache based on something other than just the URL. - `const PageRuleNewParamsActionsCacheKeyFieldsIDCacheKeyFields PageRuleNewParamsActionsCacheKeyFieldsID = "cache_key_fields"` - `Value PageRuleNewParamsActionsCacheKeyFieldsValue` - `Cookie PageRuleNewParamsActionsCacheKeyFieldsValueCookie` Controls which cookies appear in the Cache Key. - `CheckPresence []string` A list of cookies to check for the presence of, without including their actual values. - `Include []string` A list of cookies to include. - `Header PageRuleNewParamsActionsCacheKeyFieldsValueHeader` Controls which headers go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `CheckPresence []string` A list of headers to check for the presence of, without including their actual values. - `Exclude []string` A list of headers to ignore. - `Include []string` A list of headers to include. - `Host PageRuleNewParamsActionsCacheKeyFieldsValueHost` Determines which host header to include in the Cache Key. - `Resolved bool` Whether to include the Host header in the HTTP request sent to the origin. - `QueryString PageRuleNewParamsActionsCacheKeyFieldsValueQueryString` Controls which URL query string parameters go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `Exclude PageRuleNewParamsActionsCacheKeyFieldsValueQueryStringExcludeUnion` Ignore all query string parameters. - `type PageRuleNewParamsActionsCacheKeyFieldsValueQueryStringExcludeString string` Ignore all query string parameters. - `const PageRuleNewParamsActionsCacheKeyFieldsValueQueryStringExcludeStringStar PageRuleNewParamsActionsCacheKeyFieldsValueQueryStringExcludeString = "*"` - `type PageRuleNewParamsActionsCacheKeyFieldsValueQueryStringExcludeArray []string` A list of query string parameters to ignore. - `Include PageRuleNewParamsActionsCacheKeyFieldsValueQueryStringIncludeUnion` Include all query string parameters. - `type PageRuleNewParamsActionsCacheKeyFieldsValueQueryStringIncludeString string` Include all query string parameters. - `const PageRuleNewParamsActionsCacheKeyFieldsValueQueryStringIncludeStringStar PageRuleNewParamsActionsCacheKeyFieldsValueQueryStringIncludeString = "*"` - `type PageRuleNewParamsActionsCacheKeyFieldsValueQueryStringIncludeArray []string` A list of query string parameters to include. - `User PageRuleNewParamsActionsCacheKeyFieldsValueUser` Feature fields to add features about the end-user (client) into the Cache Key. - `DeviceType bool` Classifies a request as `mobile`, `desktop`, or `tablet` based on the User Agent. - `Geo bool` Includes the client's country, derived from the IP address. - `Lang bool` Includes the first language code contained in the `Accept-Language` header sent by the client. - `type CacheLevel struct{…}` - `ID CacheLevelID` Apply custom caching based on the option selected. - `const CacheLevelIDCacheLevel CacheLevelID = "cache_level"` - `Value CacheLevelValue` * `bypass`: Cloudflare does not cache. * `basic`: Delivers resources from cache when there is no query string. * `simplified`: Delivers the same resource to everyone independent of the query string. * `aggressive`: Caches all static content that has a query string. * `cache_everything`: Treats all content as static and caches all file types beyond the [Cloudflare default cached content](https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#default-cached-file-extensions). - `const CacheLevelValueBypass CacheLevelValue = "bypass"` - `const CacheLevelValueBasic CacheLevelValue = "basic"` - `const CacheLevelValueSimplified CacheLevelValue = "simplified"` - `const CacheLevelValueAggressive CacheLevelValue = "aggressive"` - `const CacheLevelValueCacheEverything CacheLevelValue = "cache_everything"` - `type PageRuleNewParamsActionsCacheOnCookie struct{…}` - `ID PageRuleNewParamsActionsCacheOnCookieID` Apply the Cache Everything option (Cache Level setting) based on a regular expression match against a cookie name. - `const PageRuleNewParamsActionsCacheOnCookieIDCacheOnCookie PageRuleNewParamsActionsCacheOnCookieID = "cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. - `type PageRuleNewParamsActionsCacheTTLByStatus struct{…}` - `ID PageRuleNewParamsActionsCacheTTLByStatusID` Enterprise customers can set cache time-to-live (TTL) based on the response status from the origin web server. Cache TTL refers to the duration of a resource in the Cloudflare network before being marked as stale or discarded from cache. Status codes are returned by a resource's origin. Setting cache TTL based on response status overrides the default cache behavior (standard caching) for static files and overrides cache instructions sent by the origin web server. To cache non-static assets, set a Cache Level of Cache Everything using a Page Rule. Setting no-store Cache-Control or a low TTL (using `max-age`/`s-maxage`) increases requests to origin web servers and decreases performance. - `const PageRuleNewParamsActionsCacheTTLByStatusIDCacheTTLByStatus PageRuleNewParamsActionsCacheTTLByStatusID = "cache_ttl_by_status"` - `Value map[string, PageRuleNewParamsActionsCacheTTLByStatusValueUnion]` A JSON object containing status codes and their corresponding TTLs. Each key-value pair in the cache TTL by status cache rule has the following syntax - `status_code`: An integer value such as 200 or 500. status_code matches the exact status code from the origin web server. Valid status codes are between 100-999. - `status_code_range`: Integer values for from and to. status_code_range matches any status code from the origin web server within the specified range. - `value`: An integer value that defines the duration an asset is valid in seconds or one of the following strings: no-store (equivalent to -1), no-cache (equivalent to 0). - `type PageRuleNewParamsActionsCacheTTLByStatusValueString string` `no-store` (equivalent to -1), `no-cache` (equivalent to 0) - `const PageRuleNewParamsActionsCacheTTLByStatusValueStringNoCache PageRuleNewParamsActionsCacheTTLByStatusValueString = "no-cache"` - `const PageRuleNewParamsActionsCacheTTLByStatusValueStringNoStore PageRuleNewParamsActionsCacheTTLByStatusValueString = "no-store"` - `UnionInt` - `type PageRuleNewParamsActionsDisableApps struct{…}` - `ID PageRuleNewParamsActionsDisableAppsID` Turn off all active [Cloudflare Apps](https://developers.cloudflare.com/support/more-dashboard-apps/cloudflare-apps/) (deprecated). - `const PageRuleNewParamsActionsDisableAppsIDDisableApps PageRuleNewParamsActionsDisableAppsID = "disable_apps"` - `type PageRuleNewParamsActionsDisablePerformance struct{…}` - `ID PageRuleNewParamsActionsDisablePerformanceID` Turn off [Rocket Loader](https://developers.cloudflare.com/speed/optimization/content/rocket-loader/), and [Polish](https://developers.cloudflare.com/images/polish/). - `const PageRuleNewParamsActionsDisablePerformanceIDDisablePerformance PageRuleNewParamsActionsDisablePerformanceID = "disable_performance"` - `type PageRuleNewParamsActionsDisableSecurity struct{…}` - `ID PageRuleNewParamsActionsDisableSecurityID` Turn off [Email Obfuscation](https://developers.cloudflare.com/waf/tools/scrape-shield/email-address-obfuscation/), [Rate Limiting (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/), [Scrape Shield](https://developers.cloudflare.com/waf/tools/scrape-shield/), [URL (Zone) Lockdown](https://developers.cloudflare.com/waf/tools/zone-lockdown/), and [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). - `const PageRuleNewParamsActionsDisableSecurityIDDisableSecurity PageRuleNewParamsActionsDisableSecurityID = "disable_security"` - `type PageRuleNewParamsActionsDisableZaraz struct{…}` - `ID PageRuleNewParamsActionsDisableZarazID` Turn off [Zaraz](https://developers.cloudflare.com/zaraz/). - `const PageRuleNewParamsActionsDisableZarazIDDisableZaraz PageRuleNewParamsActionsDisableZarazID = "disable_zaraz"` - `type PageRuleNewParamsActionsEdgeCacheTTL struct{…}` - `ID PageRuleNewParamsActionsEdgeCacheTTLID` Specify how long to cache a resource in the Cloudflare global network. *Edge Cache TTL* is not visible in response headers. - `const PageRuleNewParamsActionsEdgeCacheTTLIDEdgeCacheTTL PageRuleNewParamsActionsEdgeCacheTTLID = "edge_cache_ttl"` - `Value int64` - `type EmailObfuscation struct{…}` - `ID EmailObfuscationID` Turn on or off **Email Obfuscation**. - `const EmailObfuscationIDEmailObfuscation EmailObfuscationID = "email_obfuscation"` - `Value EmailObfuscationValue` The status of Email Obfuscation. - `const EmailObfuscationValueOn EmailObfuscationValue = "on"` - `const EmailObfuscationValueOff EmailObfuscationValue = "off"` - `type PageRuleNewParamsActionsExplicitCacheControl struct{…}` - `ID PageRuleNewParamsActionsExplicitCacheControlID` Origin Cache Control is enabled by default for Free, Pro, and Business domains and disabled by default for Enterprise domains. - `const PageRuleNewParamsActionsExplicitCacheControlIDExplicitCacheControl PageRuleNewParamsActionsExplicitCacheControlID = "explicit_cache_control"` - `Value PageRuleNewParamsActionsExplicitCacheControlValue` The status of Origin Cache Control. - `const PageRuleNewParamsActionsExplicitCacheControlValueOn PageRuleNewParamsActionsExplicitCacheControlValue = "on"` - `const PageRuleNewParamsActionsExplicitCacheControlValueOff PageRuleNewParamsActionsExplicitCacheControlValue = "off"` - `type PageRuleNewParamsActionsForwardingURL struct{…}` - `ID PageRuleNewParamsActionsForwardingURLID` Redirects one URL to another using an `HTTP 301/302` redirect. Refer to [Wildcard matching and referencing](https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/). - `const PageRuleNewParamsActionsForwardingURLIDForwardingURL PageRuleNewParamsActionsForwardingURLID = "forwarding_url"` - `Value PageRuleNewParamsActionsForwardingURLValue` - `StatusCode PageRuleNewParamsActionsForwardingURLValueStatusCode` The status code to use for the URL redirect. 301 is a permanent redirect. 302 is a temporary redirect. - `const PageRuleNewParamsActionsForwardingURLValueStatusCode301 PageRuleNewParamsActionsForwardingURLValueStatusCode = 301` - `const PageRuleNewParamsActionsForwardingURLValueStatusCode302 PageRuleNewParamsActionsForwardingURLValueStatusCode = 302` - `URL string` The URL to redirect the request to. Notes: ${num} refers to the position of '*' in the constraint value. - `type PageRuleNewParamsActionsHostHeaderOverride struct{…}` - `ID PageRuleNewParamsActionsHostHeaderOverrideID` Apply a specific host header. - `const PageRuleNewParamsActionsHostHeaderOverrideIDHostHeaderOverride PageRuleNewParamsActionsHostHeaderOverrideID = "host_header_override"` - `Value string` The hostname to use in the `Host` header - `type IPGeolocation struct{…}` - `ID IPGeolocationID` Cloudflare adds a CF-IPCountry HTTP header containing the country code that corresponds to the visitor. - `const IPGeolocationIDIPGeolocation IPGeolocationID = "ip_geolocation"` - `Value IPGeolocationValue` The status of adding the IP Geolocation Header. - `const IPGeolocationValueOn IPGeolocationValue = "on"` - `const IPGeolocationValueOff IPGeolocationValue = "off"` - `type Mirage struct{…}` - `ID MirageID` Cloudflare Mirage reduces bandwidth used by images in mobile browsers. It can accelerate loading of image-heavy websites on very slow mobile connections and HTTP/1. - `const MirageIDMirage MirageID = "mirage"` - `Value MirageValue` The status of Mirage. - `const MirageValueOn MirageValue = "on"` - `const MirageValueOff MirageValue = "off"` - `type OpportunisticEncryption struct{…}` - `ID OpportunisticEncryptionID` Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted TLS channel. It's not a substitute for HTTPS, but provides additional security for otherwise vulnerable requests. - `const OpportunisticEncryptionIDOpportunisticEncryption OpportunisticEncryptionID = "opportunistic_encryption"` - `Value OpportunisticEncryptionValue` The status of Opportunistic Encryption. - `const OpportunisticEncryptionValueOn OpportunisticEncryptionValue = "on"` - `const OpportunisticEncryptionValueOff OpportunisticEncryptionValue = "off"` - `type OriginErrorPagePassThru struct{…}` - `ID OriginErrorPagePassThruID` Turn on or off Cloudflare error pages generated from issues sent from the origin server. If enabled, this setting triggers error pages issued by the origin. - `const OriginErrorPagePassThruIDOriginErrorPagePassThru OriginErrorPagePassThruID = "origin_error_page_pass_thru"` - `Value OriginErrorPagePassThruValue` The status of Origin Error Page Passthru. - `const OriginErrorPagePassThruValueOn OriginErrorPagePassThruValue = "on"` - `const OriginErrorPagePassThruValueOff OriginErrorPagePassThruValue = "off"` - `type Polish struct{…}` - `ID PolishID` Apply options from the Polish feature of the Cloudflare Speed app. - `const PolishIDPolish PolishID = "polish"` - `Value PolishValue` The level of Polish you want applied to your origin. - `const PolishValueOff PolishValue = "off"` - `const PolishValueLossless PolishValue = "lossless"` - `const PolishValueLossy PolishValue = "lossy"` - `type PageRuleNewParamsActionsResolveOverride struct{…}` - `ID PageRuleNewParamsActionsResolveOverrideID` Change the origin address to the value specified in this setting. - `const PageRuleNewParamsActionsResolveOverrideIDResolveOverride PageRuleNewParamsActionsResolveOverrideID = "resolve_override"` - `Value string` The origin address you want to override with. - `type PageRuleNewParamsActionsRespectStrongEtag struct{…}` - `ID PageRuleNewParamsActionsRespectStrongEtagID` Turn on or off byte-for-byte equivalency checks between the Cloudflare cache and the origin server. - `const PageRuleNewParamsActionsRespectStrongEtagIDRespectStrongEtag PageRuleNewParamsActionsRespectStrongEtagID = "respect_strong_etag"` - `Value PageRuleNewParamsActionsRespectStrongEtagValue` The status of Respect Strong ETags - `const PageRuleNewParamsActionsRespectStrongEtagValueOn PageRuleNewParamsActionsRespectStrongEtagValue = "on"` - `const PageRuleNewParamsActionsRespectStrongEtagValueOff PageRuleNewParamsActionsRespectStrongEtagValue = "off"` - `type ResponseBuffering struct{…}` - `ID ResponseBufferingID` Turn on or off whether Cloudflare should wait for an entire file from the origin server before forwarding it to the site visitor. By default, Cloudflare sends packets to the client as they arrive from the origin server. - `const ResponseBufferingIDResponseBuffering ResponseBufferingID = "response_buffering"` - `Value ResponseBufferingValue` The status of Response Buffering - `const ResponseBufferingValueOn ResponseBufferingValue = "on"` - `const ResponseBufferingValueOff ResponseBufferingValue = "off"` - `type RocketLoader struct{…}` - `ID RocketLoaderID` Turn on or off Rocket Loader in the Cloudflare Speed app. - `const RocketLoaderIDRocketLoader RocketLoaderID = "rocket_loader"` - `Value RocketLoaderValue` The status of Rocket Loader - `const RocketLoaderValueOn RocketLoaderValue = "on"` - `const RocketLoaderValueOff RocketLoaderValue = "off"` - `type SecurityLevel struct{…}` - `ID SecurityLevelID` Control options for the **Security Level** feature from the **Security** app. - `const SecurityLevelIDSecurityLevel SecurityLevelID = "security_level"` - `Value SecurityLevelValue` - `const SecurityLevelValueOff SecurityLevelValue = "off"` - `const SecurityLevelValueEssentiallyOff SecurityLevelValue = "essentially_off"` - `const SecurityLevelValueLow SecurityLevelValue = "low"` - `const SecurityLevelValueMedium SecurityLevelValue = "medium"` - `const SecurityLevelValueHigh SecurityLevelValue = "high"` - `const SecurityLevelValueUnderAttack SecurityLevelValue = "under_attack"` - `type SortQueryStringForCache struct{…}` - `ID SortQueryStringForCacheID` Turn on or off the reordering of query strings. When query strings have the same structure, caching improves. - `const SortQueryStringForCacheIDSortQueryStringForCache SortQueryStringForCacheID = "sort_query_string_for_cache"` - `Value SortQueryStringForCacheValue` The status of Query String Sort - `const SortQueryStringForCacheValueOn SortQueryStringForCacheValue = "on"` - `const SortQueryStringForCacheValueOff SortQueryStringForCacheValue = "off"` - `type SSL struct{…}` - `ID SSLID` Control options for the SSL feature of the Edge Certificates tab in the Cloudflare SSL/TLS app. - `const SSLIDSSL SSLID = "ssl"` - `Value SSLValue` The encryption mode that Cloudflare uses to connect to your origin server. - `const SSLValueOff SSLValue = "off"` - `const SSLValueFlexible SSLValue = "flexible"` - `const SSLValueFull SSLValue = "full"` - `const SSLValueStrict SSLValue = "strict"` - `const SSLValueOriginPull SSLValue = "origin_pull"` - `type TrueClientIPHeader struct{…}` - `ID TrueClientIPHeaderID` Turn on or off the True-Client-IP Header feature of the Cloudflare Network app. - `const TrueClientIPHeaderIDTrueClientIPHeader TrueClientIPHeaderID = "true_client_ip_header"` - `Value TrueClientIPHeaderValue` The status of True Client IP Header. - `const TrueClientIPHeaderValueOn TrueClientIPHeaderValue = "on"` - `const TrueClientIPHeaderValueOff TrueClientIPHeaderValue = "off"` - `type WAF struct{…}` - `ID WAFID` Turn on or off [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). You cannot enable or disable individual WAF managed rules via Page Rules. - `const WAFIDWAF WAFID = "waf"` - `Value WAFValue` The status of WAF managed rules (previous version). - `const WAFValueOn WAFValue = "on"` - `const WAFValueOff WAFValue = "off"` - `Targets param.Field[[]Target]` Body param: The rule targets to evaluate on each request. - `Constraint TargetConstraint` String constraint. - `Operator TargetConstraintOperator` The matches operator can use asterisks and pipes as wildcard and 'or' operators. - `const TargetConstraintOperatorMatches TargetConstraintOperator = "matches"` - `const TargetConstraintOperatorContains TargetConstraintOperator = "contains"` - `const TargetConstraintOperatorEquals TargetConstraintOperator = "equals"` - `const TargetConstraintOperatorNotEqual TargetConstraintOperator = "not_equal"` - `const TargetConstraintOperatorNotContain TargetConstraintOperator = "not_contain"` - `Value string` The URL pattern to match against the current request. The pattern may contain up to four asterisks ('*') as placeholders. - `Target TargetTarget` A target based on the URL of the request. - `const TargetTargetURL TargetTarget = "url"` - `Priority param.Field[int64]` Body param: The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: `/images/*`) but want a more specific Page Rule to take precedence (rule B: `/images/special/*`), specify a higher priority for rule B so it overrides rule A. - `Status param.Field[PageRuleNewParamsStatus]` Body param: The status of the Page Rule. - `const PageRuleNewParamsStatusActive PageRuleNewParamsStatus = "active"` - `const PageRuleNewParamsStatusDisabled PageRuleNewParamsStatus = "disabled"` ### Returns - `type PageRule struct{…}` - `ID string` Identifier. - `Actions []PageRuleAction` The set of actions to perform if the targets of this rule match the request. Actions can redirect to another URL or override settings, but not both. - `type AlwaysUseHTTPS struct{…}` - `ID AlwaysUseHTTPSID` If enabled, any `http://`` URL is converted to`https://` through a 301 redirect. - `const AlwaysUseHTTPSIDAlwaysUseHTTPS AlwaysUseHTTPSID = "always_use_https"` - `type AutomaticHTTPSRewrites struct{…}` - `ID AutomaticHTTPSRewritesID` Turn on or off Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesIDAutomaticHTTPSRewrites AutomaticHTTPSRewritesID = "automatic_https_rewrites"` - `Value AutomaticHTTPSRewritesValue` The status of Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesValueOn AutomaticHTTPSRewritesValue = "on"` - `const AutomaticHTTPSRewritesValueOff AutomaticHTTPSRewritesValue = "off"` - `type BrowserCacheTTL struct{…}` - `ID BrowserCacheTTLID` Control how long resources cached by client browsers remain valid. - `const BrowserCacheTTLIDBrowserCacheTTL BrowserCacheTTLID = "browser_cache_ttl"` - `Value int64` The number of seconds to cache resources for. Setting this to 0 enables "Respect Existing Headers". - `type BrowserCheck struct{…}` - `ID BrowserCheckID` Inspect the visitor's browser for headers commonly associated with spammers and certain bots. - `const BrowserCheckIDBrowserCheck BrowserCheckID = "browser_check"` - `Value BrowserCheckValue` The status of Browser Integrity Check. - `const BrowserCheckValueOn BrowserCheckValue = "on"` - `const BrowserCheckValueOff BrowserCheckValue = "off"` - `type PageRuleActionsBypassCacheOnCookie struct{…}` - `ID PageRuleActionsBypassCacheOnCookieID` Bypass cache and fetch resources from the origin server if a regular expression matches against a cookie name present in the request. - `const PageRuleActionsBypassCacheOnCookieIDBypassCacheOnCookie PageRuleActionsBypassCacheOnCookieID = "bypass_cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. Refer to [Bypass Cache on Cookie setting](https://developers.cloudflare.com/rules/page-rules/reference/additional-reference/#bypass-cache-on-cookie-setting) to learn about limited regular expression support. - `type PageRuleActionsCacheByDeviceType struct{…}` - `ID PageRuleActionsCacheByDeviceTypeID` Separate cached content based on the visitor's device type. - `const PageRuleActionsCacheByDeviceTypeIDCacheByDeviceType PageRuleActionsCacheByDeviceTypeID = "cache_by_device_type"` - `Value PageRuleActionsCacheByDeviceTypeValue` The status of Cache By Device Type. - `const PageRuleActionsCacheByDeviceTypeValueOn PageRuleActionsCacheByDeviceTypeValue = "on"` - `const PageRuleActionsCacheByDeviceTypeValueOff PageRuleActionsCacheByDeviceTypeValue = "off"` - `type PageRuleActionsCacheDeceptionArmor struct{…}` - `ID PageRuleActionsCacheDeceptionArmorID` Protect from web cache deception attacks while still allowing static assets to be cached. This setting verifies that the URL's extension matches the returned `Content-Type`. - `const PageRuleActionsCacheDeceptionArmorIDCacheDeceptionArmor PageRuleActionsCacheDeceptionArmorID = "cache_deception_armor"` - `Value PageRuleActionsCacheDeceptionArmorValue` The status of Cache Deception Armor. - `const PageRuleActionsCacheDeceptionArmorValueOn PageRuleActionsCacheDeceptionArmorValue = "on"` - `const PageRuleActionsCacheDeceptionArmorValueOff PageRuleActionsCacheDeceptionArmorValue = "off"` - `type PageRuleActionsCacheKeyFields struct{…}` - `ID PageRuleActionsCacheKeyFieldsID` Control specifically what variables to include when deciding which resources to cache. This allows customers to determine what to cache based on something other than just the URL. - `const PageRuleActionsCacheKeyFieldsIDCacheKeyFields PageRuleActionsCacheKeyFieldsID = "cache_key_fields"` - `Value PageRuleActionsCacheKeyFieldsValue` - `Cookie PageRuleActionsCacheKeyFieldsValueCookie` Controls which cookies appear in the Cache Key. - `CheckPresence []string` A list of cookies to check for the presence of, without including their actual values. - `Include []string` A list of cookies to include. - `Header PageRuleActionsCacheKeyFieldsValueHeader` Controls which headers go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `CheckPresence []string` A list of headers to check for the presence of, without including their actual values. - `Exclude []string` A list of headers to ignore. - `Include []string` A list of headers to include. - `Host PageRuleActionsCacheKeyFieldsValueHost` Determines which host header to include in the Cache Key. - `Resolved bool` Whether to include the Host header in the HTTP request sent to the origin. - `QueryString PageRuleActionsCacheKeyFieldsValueQueryString` Controls which URL query string parameters go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `Exclude PageRuleActionsCacheKeyFieldsValueQueryStringExcludeUnion` Ignore all query string parameters. - `type PageRuleActionsCacheKeyFieldsValueQueryStringExcludeString string` Ignore all query string parameters. - `const PageRuleActionsCacheKeyFieldsValueQueryStringExcludeStringStar PageRuleActionsCacheKeyFieldsValueQueryStringExcludeString = "*"` - `type PageRuleActionsCacheKeyFieldsValueQueryStringExcludeArray []string` A list of query string parameters to ignore. - `Include PageRuleActionsCacheKeyFieldsValueQueryStringIncludeUnion` Include all query string parameters. - `type PageRuleActionsCacheKeyFieldsValueQueryStringIncludeString string` Include all query string parameters. - `const PageRuleActionsCacheKeyFieldsValueQueryStringIncludeStringStar PageRuleActionsCacheKeyFieldsValueQueryStringIncludeString = "*"` - `type PageRuleActionsCacheKeyFieldsValueQueryStringIncludeArray []string` A list of query string parameters to include. - `User PageRuleActionsCacheKeyFieldsValueUser` Feature fields to add features about the end-user (client) into the Cache Key. - `DeviceType bool` Classifies a request as `mobile`, `desktop`, or `tablet` based on the User Agent. - `Geo bool` Includes the client's country, derived from the IP address. - `Lang bool` Includes the first language code contained in the `Accept-Language` header sent by the client. - `type CacheLevel struct{…}` - `ID CacheLevelID` Apply custom caching based on the option selected. - `const CacheLevelIDCacheLevel CacheLevelID = "cache_level"` - `Value CacheLevelValue` * `bypass`: Cloudflare does not cache. * `basic`: Delivers resources from cache when there is no query string. * `simplified`: Delivers the same resource to everyone independent of the query string. * `aggressive`: Caches all static content that has a query string. * `cache_everything`: Treats all content as static and caches all file types beyond the [Cloudflare default cached content](https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#default-cached-file-extensions). - `const CacheLevelValueBypass CacheLevelValue = "bypass"` - `const CacheLevelValueBasic CacheLevelValue = "basic"` - `const CacheLevelValueSimplified CacheLevelValue = "simplified"` - `const CacheLevelValueAggressive CacheLevelValue = "aggressive"` - `const CacheLevelValueCacheEverything CacheLevelValue = "cache_everything"` - `type PageRuleActionsCacheOnCookie struct{…}` - `ID PageRuleActionsCacheOnCookieID` Apply the Cache Everything option (Cache Level setting) based on a regular expression match against a cookie name. - `const PageRuleActionsCacheOnCookieIDCacheOnCookie PageRuleActionsCacheOnCookieID = "cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. - `type PageRuleActionsCacheTTLByStatus struct{…}` - `ID PageRuleActionsCacheTTLByStatusID` Enterprise customers can set cache time-to-live (TTL) based on the response status from the origin web server. Cache TTL refers to the duration of a resource in the Cloudflare network before being marked as stale or discarded from cache. Status codes are returned by a resource's origin. Setting cache TTL based on response status overrides the default cache behavior (standard caching) for static files and overrides cache instructions sent by the origin web server. To cache non-static assets, set a Cache Level of Cache Everything using a Page Rule. Setting no-store Cache-Control or a low TTL (using `max-age`/`s-maxage`) increases requests to origin web servers and decreases performance. - `const PageRuleActionsCacheTTLByStatusIDCacheTTLByStatus PageRuleActionsCacheTTLByStatusID = "cache_ttl_by_status"` - `Value map[string, PageRuleActionsCacheTTLByStatusValueUnion]` A JSON object containing status codes and their corresponding TTLs. Each key-value pair in the cache TTL by status cache rule has the following syntax - `status_code`: An integer value such as 200 or 500. status_code matches the exact status code from the origin web server. Valid status codes are between 100-999. - `status_code_range`: Integer values for from and to. status_code_range matches any status code from the origin web server within the specified range. - `value`: An integer value that defines the duration an asset is valid in seconds or one of the following strings: no-store (equivalent to -1), no-cache (equivalent to 0). - `type PageRuleActionsCacheTTLByStatusValueString string` `no-store` (equivalent to -1), `no-cache` (equivalent to 0) - `const PageRuleActionsCacheTTLByStatusValueStringNoCache PageRuleActionsCacheTTLByStatusValueString = "no-cache"` - `const PageRuleActionsCacheTTLByStatusValueStringNoStore PageRuleActionsCacheTTLByStatusValueString = "no-store"` - `UnionInt` - `type PageRuleActionsDisableApps struct{…}` - `ID PageRuleActionsDisableAppsID` Turn off all active [Cloudflare Apps](https://developers.cloudflare.com/support/more-dashboard-apps/cloudflare-apps/) (deprecated). - `const PageRuleActionsDisableAppsIDDisableApps PageRuleActionsDisableAppsID = "disable_apps"` - `type PageRuleActionsDisablePerformance struct{…}` - `ID PageRuleActionsDisablePerformanceID` Turn off [Rocket Loader](https://developers.cloudflare.com/speed/optimization/content/rocket-loader/), and [Polish](https://developers.cloudflare.com/images/polish/). - `const PageRuleActionsDisablePerformanceIDDisablePerformance PageRuleActionsDisablePerformanceID = "disable_performance"` - `type PageRuleActionsDisableSecurity struct{…}` - `ID PageRuleActionsDisableSecurityID` Turn off [Email Obfuscation](https://developers.cloudflare.com/waf/tools/scrape-shield/email-address-obfuscation/), [Rate Limiting (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/), [Scrape Shield](https://developers.cloudflare.com/waf/tools/scrape-shield/), [URL (Zone) Lockdown](https://developers.cloudflare.com/waf/tools/zone-lockdown/), and [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). - `const PageRuleActionsDisableSecurityIDDisableSecurity PageRuleActionsDisableSecurityID = "disable_security"` - `type PageRuleActionsDisableZaraz struct{…}` - `ID PageRuleActionsDisableZarazID` Turn off [Zaraz](https://developers.cloudflare.com/zaraz/). - `const PageRuleActionsDisableZarazIDDisableZaraz PageRuleActionsDisableZarazID = "disable_zaraz"` - `type PageRuleActionsEdgeCacheTTL struct{…}` - `ID PageRuleActionsEdgeCacheTTLID` Specify how long to cache a resource in the Cloudflare global network. *Edge Cache TTL* is not visible in response headers. - `const PageRuleActionsEdgeCacheTTLIDEdgeCacheTTL PageRuleActionsEdgeCacheTTLID = "edge_cache_ttl"` - `Value int64` - `type EmailObfuscation struct{…}` - `ID EmailObfuscationID` Turn on or off **Email Obfuscation**. - `const EmailObfuscationIDEmailObfuscation EmailObfuscationID = "email_obfuscation"` - `Value EmailObfuscationValue` The status of Email Obfuscation. - `const EmailObfuscationValueOn EmailObfuscationValue = "on"` - `const EmailObfuscationValueOff EmailObfuscationValue = "off"` - `type PageRuleActionsExplicitCacheControl struct{…}` - `ID PageRuleActionsExplicitCacheControlID` Origin Cache Control is enabled by default for Free, Pro, and Business domains and disabled by default for Enterprise domains. - `const PageRuleActionsExplicitCacheControlIDExplicitCacheControl PageRuleActionsExplicitCacheControlID = "explicit_cache_control"` - `Value PageRuleActionsExplicitCacheControlValue` The status of Origin Cache Control. - `const PageRuleActionsExplicitCacheControlValueOn PageRuleActionsExplicitCacheControlValue = "on"` - `const PageRuleActionsExplicitCacheControlValueOff PageRuleActionsExplicitCacheControlValue = "off"` - `type PageRuleActionsForwardingURL struct{…}` - `ID PageRuleActionsForwardingURLID` Redirects one URL to another using an `HTTP 301/302` redirect. Refer to [Wildcard matching and referencing](https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/). - `const PageRuleActionsForwardingURLIDForwardingURL PageRuleActionsForwardingURLID = "forwarding_url"` - `Value PageRuleActionsForwardingURLValue` - `StatusCode PageRuleActionsForwardingURLValueStatusCode` The status code to use for the URL redirect. 301 is a permanent redirect. 302 is a temporary redirect. - `const PageRuleActionsForwardingURLValueStatusCode301 PageRuleActionsForwardingURLValueStatusCode = 301` - `const PageRuleActionsForwardingURLValueStatusCode302 PageRuleActionsForwardingURLValueStatusCode = 302` - `URL string` The URL to redirect the request to. Notes: ${num} refers to the position of '*' in the constraint value. - `type PageRuleActionsHostHeaderOverride struct{…}` - `ID PageRuleActionsHostHeaderOverrideID` Apply a specific host header. - `const PageRuleActionsHostHeaderOverrideIDHostHeaderOverride PageRuleActionsHostHeaderOverrideID = "host_header_override"` - `Value string` The hostname to use in the `Host` header - `type IPGeolocation struct{…}` - `ID IPGeolocationID` Cloudflare adds a CF-IPCountry HTTP header containing the country code that corresponds to the visitor. - `const IPGeolocationIDIPGeolocation IPGeolocationID = "ip_geolocation"` - `Value IPGeolocationValue` The status of adding the IP Geolocation Header. - `const IPGeolocationValueOn IPGeolocationValue = "on"` - `const IPGeolocationValueOff IPGeolocationValue = "off"` - `type Mirage struct{…}` - `ID MirageID` Cloudflare Mirage reduces bandwidth used by images in mobile browsers. It can accelerate loading of image-heavy websites on very slow mobile connections and HTTP/1. - `const MirageIDMirage MirageID = "mirage"` - `Value MirageValue` The status of Mirage. - `const MirageValueOn MirageValue = "on"` - `const MirageValueOff MirageValue = "off"` - `type OpportunisticEncryption struct{…}` - `ID OpportunisticEncryptionID` Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted TLS channel. It's not a substitute for HTTPS, but provides additional security for otherwise vulnerable requests. - `const OpportunisticEncryptionIDOpportunisticEncryption OpportunisticEncryptionID = "opportunistic_encryption"` - `Value OpportunisticEncryptionValue` The status of Opportunistic Encryption. - `const OpportunisticEncryptionValueOn OpportunisticEncryptionValue = "on"` - `const OpportunisticEncryptionValueOff OpportunisticEncryptionValue = "off"` - `type OriginErrorPagePassThru struct{…}` - `ID OriginErrorPagePassThruID` Turn on or off Cloudflare error pages generated from issues sent from the origin server. If enabled, this setting triggers error pages issued by the origin. - `const OriginErrorPagePassThruIDOriginErrorPagePassThru OriginErrorPagePassThruID = "origin_error_page_pass_thru"` - `Value OriginErrorPagePassThruValue` The status of Origin Error Page Passthru. - `const OriginErrorPagePassThruValueOn OriginErrorPagePassThruValue = "on"` - `const OriginErrorPagePassThruValueOff OriginErrorPagePassThruValue = "off"` - `type Polish struct{…}` - `ID PolishID` Apply options from the Polish feature of the Cloudflare Speed app. - `const PolishIDPolish PolishID = "polish"` - `Value PolishValue` The level of Polish you want applied to your origin. - `const PolishValueOff PolishValue = "off"` - `const PolishValueLossless PolishValue = "lossless"` - `const PolishValueLossy PolishValue = "lossy"` - `type PageRuleActionsResolveOverride struct{…}` - `ID PageRuleActionsResolveOverrideID` Change the origin address to the value specified in this setting. - `const PageRuleActionsResolveOverrideIDResolveOverride PageRuleActionsResolveOverrideID = "resolve_override"` - `Value string` The origin address you want to override with. - `type PageRuleActionsRespectStrongEtag struct{…}` - `ID PageRuleActionsRespectStrongEtagID` Turn on or off byte-for-byte equivalency checks between the Cloudflare cache and the origin server. - `const PageRuleActionsRespectStrongEtagIDRespectStrongEtag PageRuleActionsRespectStrongEtagID = "respect_strong_etag"` - `Value PageRuleActionsRespectStrongEtagValue` The status of Respect Strong ETags - `const PageRuleActionsRespectStrongEtagValueOn PageRuleActionsRespectStrongEtagValue = "on"` - `const PageRuleActionsRespectStrongEtagValueOff PageRuleActionsRespectStrongEtagValue = "off"` - `type ResponseBuffering struct{…}` - `ID ResponseBufferingID` Turn on or off whether Cloudflare should wait for an entire file from the origin server before forwarding it to the site visitor. By default, Cloudflare sends packets to the client as they arrive from the origin server. - `const ResponseBufferingIDResponseBuffering ResponseBufferingID = "response_buffering"` - `Value ResponseBufferingValue` The status of Response Buffering - `const ResponseBufferingValueOn ResponseBufferingValue = "on"` - `const ResponseBufferingValueOff ResponseBufferingValue = "off"` - `type RocketLoader struct{…}` - `ID RocketLoaderID` Turn on or off Rocket Loader in the Cloudflare Speed app. - `const RocketLoaderIDRocketLoader RocketLoaderID = "rocket_loader"` - `Value RocketLoaderValue` The status of Rocket Loader - `const RocketLoaderValueOn RocketLoaderValue = "on"` - `const RocketLoaderValueOff RocketLoaderValue = "off"` - `type SecurityLevel struct{…}` - `ID SecurityLevelID` Control options for the **Security Level** feature from the **Security** app. - `const SecurityLevelIDSecurityLevel SecurityLevelID = "security_level"` - `Value SecurityLevelValue` - `const SecurityLevelValueOff SecurityLevelValue = "off"` - `const SecurityLevelValueEssentiallyOff SecurityLevelValue = "essentially_off"` - `const SecurityLevelValueLow SecurityLevelValue = "low"` - `const SecurityLevelValueMedium SecurityLevelValue = "medium"` - `const SecurityLevelValueHigh SecurityLevelValue = "high"` - `const SecurityLevelValueUnderAttack SecurityLevelValue = "under_attack"` - `type SortQueryStringForCache struct{…}` - `ID SortQueryStringForCacheID` Turn on or off the reordering of query strings. When query strings have the same structure, caching improves. - `const SortQueryStringForCacheIDSortQueryStringForCache SortQueryStringForCacheID = "sort_query_string_for_cache"` - `Value SortQueryStringForCacheValue` The status of Query String Sort - `const SortQueryStringForCacheValueOn SortQueryStringForCacheValue = "on"` - `const SortQueryStringForCacheValueOff SortQueryStringForCacheValue = "off"` - `type SSL struct{…}` - `ID SSLID` Control options for the SSL feature of the Edge Certificates tab in the Cloudflare SSL/TLS app. - `const SSLIDSSL SSLID = "ssl"` - `Value SSLValue` The encryption mode that Cloudflare uses to connect to your origin server. - `const SSLValueOff SSLValue = "off"` - `const SSLValueFlexible SSLValue = "flexible"` - `const SSLValueFull SSLValue = "full"` - `const SSLValueStrict SSLValue = "strict"` - `const SSLValueOriginPull SSLValue = "origin_pull"` - `type TrueClientIPHeader struct{…}` - `ID TrueClientIPHeaderID` Turn on or off the True-Client-IP Header feature of the Cloudflare Network app. - `const TrueClientIPHeaderIDTrueClientIPHeader TrueClientIPHeaderID = "true_client_ip_header"` - `Value TrueClientIPHeaderValue` The status of True Client IP Header. - `const TrueClientIPHeaderValueOn TrueClientIPHeaderValue = "on"` - `const TrueClientIPHeaderValueOff TrueClientIPHeaderValue = "off"` - `type WAF struct{…}` - `ID WAFID` Turn on or off [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). You cannot enable or disable individual WAF managed rules via Page Rules. - `const WAFIDWAF WAFID = "waf"` - `Value WAFValue` The status of WAF managed rules (previous version). - `const WAFValueOn WAFValue = "on"` - `const WAFValueOff WAFValue = "off"` - `CreatedOn Time` The timestamp of when the Page Rule was created. - `ModifiedOn Time` The timestamp of when the Page Rule was last modified. - `Priority int64` The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: `/images/*`) but want a more specific Page Rule to take precedence (rule B: `/images/special/*`), specify a higher priority for rule B so it overrides rule A. - `Status PageRuleStatus` The status of the Page Rule. - `const PageRuleStatusActive PageRuleStatus = "active"` - `const PageRuleStatusDisabled PageRuleStatus = "disabled"` - `Targets []Target` The rule targets to evaluate on each request. - `Constraint TargetConstraint` String constraint. - `Operator TargetConstraintOperator` The matches operator can use asterisks and pipes as wildcard and 'or' operators. - `const TargetConstraintOperatorMatches TargetConstraintOperator = "matches"` - `const TargetConstraintOperatorContains TargetConstraintOperator = "contains"` - `const TargetConstraintOperatorEquals TargetConstraintOperator = "equals"` - `const TargetConstraintOperatorNotEqual TargetConstraintOperator = "not_equal"` - `const TargetConstraintOperatorNotContain TargetConstraintOperator = "not_contain"` - `Value string` The URL pattern to match against the current request. The pattern may contain up to four asterisks ('*') as placeholders. - `Target TargetTarget` A target based on the URL of the request. - `const TargetTargetURL TargetTarget = "url"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/page_rules" "github.com/cloudflare/cloudflare-go/zones" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) pageRule, err := client.PageRules.New(context.TODO(), page_rules.PageRuleNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Actions: cloudflare.F([]page_rules.PageRuleNewParamsActionUnion{zones.BrowserCheckParam{ ID: cloudflare.F(zones.BrowserCheckIDBrowserCheck), }}), Targets: cloudflare.F([]page_rules.TargetParam{page_rules.TargetParam{ Constraint: cloudflare.F(page_rules.TargetConstraintParam{ Operator: cloudflare.F(page_rules.TargetConstraintOperatorMatches), Value: cloudflare.F("*example.com/images/*"), }), Target: cloudflare.F(page_rules.TargetTargetURL), }}), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", pageRule.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353", "actions": [ { "id": "browser_check", "value": "on" } ], "created_on": "2014-01-01T05:20:00.12345Z", "modified_on": "2014-01-01T05:20:00.12345Z", "priority": 0, "status": "active", "targets": [ { "constraint": { "operator": "matches", "value": "*example.com/images/*" }, "target": "url" } ] } } ``` ## Update a Page Rule `client.PageRules.Update(ctx, pageruleID, params) (*PageRule, error)` **put** `/zones/{zone_id}/pagerules/{pagerule_id}` Replaces the configuration of an existing Page Rule. The configuration of the updated Page Rule will exactly match the data passed in the API request. ### Parameters - `pageruleID string` Identifier. - `params PageRuleUpdateParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Actions param.Field[[]PageRuleUpdateParamsAction]` Body param: The set of actions to perform if the targets of this rule match the request. Actions can redirect to another URL or override settings, but not both. - `type AlwaysUseHTTPS struct{…}` - `ID AlwaysUseHTTPSID` If enabled, any `http://`` URL is converted to`https://` through a 301 redirect. - `const AlwaysUseHTTPSIDAlwaysUseHTTPS AlwaysUseHTTPSID = "always_use_https"` - `type AutomaticHTTPSRewrites struct{…}` - `ID AutomaticHTTPSRewritesID` Turn on or off Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesIDAutomaticHTTPSRewrites AutomaticHTTPSRewritesID = "automatic_https_rewrites"` - `Value AutomaticHTTPSRewritesValue` The status of Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesValueOn AutomaticHTTPSRewritesValue = "on"` - `const AutomaticHTTPSRewritesValueOff AutomaticHTTPSRewritesValue = "off"` - `type BrowserCacheTTL struct{…}` - `ID BrowserCacheTTLID` Control how long resources cached by client browsers remain valid. - `const BrowserCacheTTLIDBrowserCacheTTL BrowserCacheTTLID = "browser_cache_ttl"` - `Value int64` The number of seconds to cache resources for. Setting this to 0 enables "Respect Existing Headers". - `type BrowserCheck struct{…}` - `ID BrowserCheckID` Inspect the visitor's browser for headers commonly associated with spammers and certain bots. - `const BrowserCheckIDBrowserCheck BrowserCheckID = "browser_check"` - `Value BrowserCheckValue` The status of Browser Integrity Check. - `const BrowserCheckValueOn BrowserCheckValue = "on"` - `const BrowserCheckValueOff BrowserCheckValue = "off"` - `type PageRuleUpdateParamsActionsBypassCacheOnCookie struct{…}` - `ID PageRuleUpdateParamsActionsBypassCacheOnCookieID` Bypass cache and fetch resources from the origin server if a regular expression matches against a cookie name present in the request. - `const PageRuleUpdateParamsActionsBypassCacheOnCookieIDBypassCacheOnCookie PageRuleUpdateParamsActionsBypassCacheOnCookieID = "bypass_cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. Refer to [Bypass Cache on Cookie setting](https://developers.cloudflare.com/rules/page-rules/reference/additional-reference/#bypass-cache-on-cookie-setting) to learn about limited regular expression support. - `type PageRuleUpdateParamsActionsCacheByDeviceType struct{…}` - `ID PageRuleUpdateParamsActionsCacheByDeviceTypeID` Separate cached content based on the visitor's device type. - `const PageRuleUpdateParamsActionsCacheByDeviceTypeIDCacheByDeviceType PageRuleUpdateParamsActionsCacheByDeviceTypeID = "cache_by_device_type"` - `Value PageRuleUpdateParamsActionsCacheByDeviceTypeValue` The status of Cache By Device Type. - `const PageRuleUpdateParamsActionsCacheByDeviceTypeValueOn PageRuleUpdateParamsActionsCacheByDeviceTypeValue = "on"` - `const PageRuleUpdateParamsActionsCacheByDeviceTypeValueOff PageRuleUpdateParamsActionsCacheByDeviceTypeValue = "off"` - `type PageRuleUpdateParamsActionsCacheDeceptionArmor struct{…}` - `ID PageRuleUpdateParamsActionsCacheDeceptionArmorID` Protect from web cache deception attacks while still allowing static assets to be cached. This setting verifies that the URL's extension matches the returned `Content-Type`. - `const PageRuleUpdateParamsActionsCacheDeceptionArmorIDCacheDeceptionArmor PageRuleUpdateParamsActionsCacheDeceptionArmorID = "cache_deception_armor"` - `Value PageRuleUpdateParamsActionsCacheDeceptionArmorValue` The status of Cache Deception Armor. - `const PageRuleUpdateParamsActionsCacheDeceptionArmorValueOn PageRuleUpdateParamsActionsCacheDeceptionArmorValue = "on"` - `const PageRuleUpdateParamsActionsCacheDeceptionArmorValueOff PageRuleUpdateParamsActionsCacheDeceptionArmorValue = "off"` - `type PageRuleUpdateParamsActionsCacheKeyFields struct{…}` - `ID PageRuleUpdateParamsActionsCacheKeyFieldsID` Control specifically what variables to include when deciding which resources to cache. This allows customers to determine what to cache based on something other than just the URL. - `const PageRuleUpdateParamsActionsCacheKeyFieldsIDCacheKeyFields PageRuleUpdateParamsActionsCacheKeyFieldsID = "cache_key_fields"` - `Value PageRuleUpdateParamsActionsCacheKeyFieldsValue` - `Cookie PageRuleUpdateParamsActionsCacheKeyFieldsValueCookie` Controls which cookies appear in the Cache Key. - `CheckPresence []string` A list of cookies to check for the presence of, without including their actual values. - `Include []string` A list of cookies to include. - `Header PageRuleUpdateParamsActionsCacheKeyFieldsValueHeader` Controls which headers go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `CheckPresence []string` A list of headers to check for the presence of, without including their actual values. - `Exclude []string` A list of headers to ignore. - `Include []string` A list of headers to include. - `Host PageRuleUpdateParamsActionsCacheKeyFieldsValueHost` Determines which host header to include in the Cache Key. - `Resolved bool` Whether to include the Host header in the HTTP request sent to the origin. - `QueryString PageRuleUpdateParamsActionsCacheKeyFieldsValueQueryString` Controls which URL query string parameters go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `Exclude PageRuleUpdateParamsActionsCacheKeyFieldsValueQueryStringExcludeUnion` Ignore all query string parameters. - `type PageRuleUpdateParamsActionsCacheKeyFieldsValueQueryStringExcludeString string` Ignore all query string parameters. - `const PageRuleUpdateParamsActionsCacheKeyFieldsValueQueryStringExcludeStringStar PageRuleUpdateParamsActionsCacheKeyFieldsValueQueryStringExcludeString = "*"` - `type PageRuleUpdateParamsActionsCacheKeyFieldsValueQueryStringExcludeArray []string` A list of query string parameters to ignore. - `Include PageRuleUpdateParamsActionsCacheKeyFieldsValueQueryStringIncludeUnion` Include all query string parameters. - `type PageRuleUpdateParamsActionsCacheKeyFieldsValueQueryStringIncludeString string` Include all query string parameters. - `const PageRuleUpdateParamsActionsCacheKeyFieldsValueQueryStringIncludeStringStar PageRuleUpdateParamsActionsCacheKeyFieldsValueQueryStringIncludeString = "*"` - `type PageRuleUpdateParamsActionsCacheKeyFieldsValueQueryStringIncludeArray []string` A list of query string parameters to include. - `User PageRuleUpdateParamsActionsCacheKeyFieldsValueUser` Feature fields to add features about the end-user (client) into the Cache Key. - `DeviceType bool` Classifies a request as `mobile`, `desktop`, or `tablet` based on the User Agent. - `Geo bool` Includes the client's country, derived from the IP address. - `Lang bool` Includes the first language code contained in the `Accept-Language` header sent by the client. - `type CacheLevel struct{…}` - `ID CacheLevelID` Apply custom caching based on the option selected. - `const CacheLevelIDCacheLevel CacheLevelID = "cache_level"` - `Value CacheLevelValue` * `bypass`: Cloudflare does not cache. * `basic`: Delivers resources from cache when there is no query string. * `simplified`: Delivers the same resource to everyone independent of the query string. * `aggressive`: Caches all static content that has a query string. * `cache_everything`: Treats all content as static and caches all file types beyond the [Cloudflare default cached content](https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#default-cached-file-extensions). - `const CacheLevelValueBypass CacheLevelValue = "bypass"` - `const CacheLevelValueBasic CacheLevelValue = "basic"` - `const CacheLevelValueSimplified CacheLevelValue = "simplified"` - `const CacheLevelValueAggressive CacheLevelValue = "aggressive"` - `const CacheLevelValueCacheEverything CacheLevelValue = "cache_everything"` - `type PageRuleUpdateParamsActionsCacheOnCookie struct{…}` - `ID PageRuleUpdateParamsActionsCacheOnCookieID` Apply the Cache Everything option (Cache Level setting) based on a regular expression match against a cookie name. - `const PageRuleUpdateParamsActionsCacheOnCookieIDCacheOnCookie PageRuleUpdateParamsActionsCacheOnCookieID = "cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. - `type PageRuleUpdateParamsActionsCacheTTLByStatus struct{…}` - `ID PageRuleUpdateParamsActionsCacheTTLByStatusID` Enterprise customers can set cache time-to-live (TTL) based on the response status from the origin web server. Cache TTL refers to the duration of a resource in the Cloudflare network before being marked as stale or discarded from cache. Status codes are returned by a resource's origin. Setting cache TTL based on response status overrides the default cache behavior (standard caching) for static files and overrides cache instructions sent by the origin web server. To cache non-static assets, set a Cache Level of Cache Everything using a Page Rule. Setting no-store Cache-Control or a low TTL (using `max-age`/`s-maxage`) increases requests to origin web servers and decreases performance. - `const PageRuleUpdateParamsActionsCacheTTLByStatusIDCacheTTLByStatus PageRuleUpdateParamsActionsCacheTTLByStatusID = "cache_ttl_by_status"` - `Value map[string, PageRuleUpdateParamsActionsCacheTTLByStatusValueUnion]` A JSON object containing status codes and their corresponding TTLs. Each key-value pair in the cache TTL by status cache rule has the following syntax - `status_code`: An integer value such as 200 or 500. status_code matches the exact status code from the origin web server. Valid status codes are between 100-999. - `status_code_range`: Integer values for from and to. status_code_range matches any status code from the origin web server within the specified range. - `value`: An integer value that defines the duration an asset is valid in seconds or one of the following strings: no-store (equivalent to -1), no-cache (equivalent to 0). - `type PageRuleUpdateParamsActionsCacheTTLByStatusValueString string` `no-store` (equivalent to -1), `no-cache` (equivalent to 0) - `const PageRuleUpdateParamsActionsCacheTTLByStatusValueStringNoCache PageRuleUpdateParamsActionsCacheTTLByStatusValueString = "no-cache"` - `const PageRuleUpdateParamsActionsCacheTTLByStatusValueStringNoStore PageRuleUpdateParamsActionsCacheTTLByStatusValueString = "no-store"` - `UnionInt` - `type PageRuleUpdateParamsActionsDisableApps struct{…}` - `ID PageRuleUpdateParamsActionsDisableAppsID` Turn off all active [Cloudflare Apps](https://developers.cloudflare.com/support/more-dashboard-apps/cloudflare-apps/) (deprecated). - `const PageRuleUpdateParamsActionsDisableAppsIDDisableApps PageRuleUpdateParamsActionsDisableAppsID = "disable_apps"` - `type PageRuleUpdateParamsActionsDisablePerformance struct{…}` - `ID PageRuleUpdateParamsActionsDisablePerformanceID` Turn off [Rocket Loader](https://developers.cloudflare.com/speed/optimization/content/rocket-loader/), and [Polish](https://developers.cloudflare.com/images/polish/). - `const PageRuleUpdateParamsActionsDisablePerformanceIDDisablePerformance PageRuleUpdateParamsActionsDisablePerformanceID = "disable_performance"` - `type PageRuleUpdateParamsActionsDisableSecurity struct{…}` - `ID PageRuleUpdateParamsActionsDisableSecurityID` Turn off [Email Obfuscation](https://developers.cloudflare.com/waf/tools/scrape-shield/email-address-obfuscation/), [Rate Limiting (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/), [Scrape Shield](https://developers.cloudflare.com/waf/tools/scrape-shield/), [URL (Zone) Lockdown](https://developers.cloudflare.com/waf/tools/zone-lockdown/), and [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). - `const PageRuleUpdateParamsActionsDisableSecurityIDDisableSecurity PageRuleUpdateParamsActionsDisableSecurityID = "disable_security"` - `type PageRuleUpdateParamsActionsDisableZaraz struct{…}` - `ID PageRuleUpdateParamsActionsDisableZarazID` Turn off [Zaraz](https://developers.cloudflare.com/zaraz/). - `const PageRuleUpdateParamsActionsDisableZarazIDDisableZaraz PageRuleUpdateParamsActionsDisableZarazID = "disable_zaraz"` - `type PageRuleUpdateParamsActionsEdgeCacheTTL struct{…}` - `ID PageRuleUpdateParamsActionsEdgeCacheTTLID` Specify how long to cache a resource in the Cloudflare global network. *Edge Cache TTL* is not visible in response headers. - `const PageRuleUpdateParamsActionsEdgeCacheTTLIDEdgeCacheTTL PageRuleUpdateParamsActionsEdgeCacheTTLID = "edge_cache_ttl"` - `Value int64` - `type EmailObfuscation struct{…}` - `ID EmailObfuscationID` Turn on or off **Email Obfuscation**. - `const EmailObfuscationIDEmailObfuscation EmailObfuscationID = "email_obfuscation"` - `Value EmailObfuscationValue` The status of Email Obfuscation. - `const EmailObfuscationValueOn EmailObfuscationValue = "on"` - `const EmailObfuscationValueOff EmailObfuscationValue = "off"` - `type PageRuleUpdateParamsActionsExplicitCacheControl struct{…}` - `ID PageRuleUpdateParamsActionsExplicitCacheControlID` Origin Cache Control is enabled by default for Free, Pro, and Business domains and disabled by default for Enterprise domains. - `const PageRuleUpdateParamsActionsExplicitCacheControlIDExplicitCacheControl PageRuleUpdateParamsActionsExplicitCacheControlID = "explicit_cache_control"` - `Value PageRuleUpdateParamsActionsExplicitCacheControlValue` The status of Origin Cache Control. - `const PageRuleUpdateParamsActionsExplicitCacheControlValueOn PageRuleUpdateParamsActionsExplicitCacheControlValue = "on"` - `const PageRuleUpdateParamsActionsExplicitCacheControlValueOff PageRuleUpdateParamsActionsExplicitCacheControlValue = "off"` - `type PageRuleUpdateParamsActionsForwardingURL struct{…}` - `ID PageRuleUpdateParamsActionsForwardingURLID` Redirects one URL to another using an `HTTP 301/302` redirect. Refer to [Wildcard matching and referencing](https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/). - `const PageRuleUpdateParamsActionsForwardingURLIDForwardingURL PageRuleUpdateParamsActionsForwardingURLID = "forwarding_url"` - `Value PageRuleUpdateParamsActionsForwardingURLValue` - `StatusCode PageRuleUpdateParamsActionsForwardingURLValueStatusCode` The status code to use for the URL redirect. 301 is a permanent redirect. 302 is a temporary redirect. - `const PageRuleUpdateParamsActionsForwardingURLValueStatusCode301 PageRuleUpdateParamsActionsForwardingURLValueStatusCode = 301` - `const PageRuleUpdateParamsActionsForwardingURLValueStatusCode302 PageRuleUpdateParamsActionsForwardingURLValueStatusCode = 302` - `URL string` The URL to redirect the request to. Notes: ${num} refers to the position of '*' in the constraint value. - `type PageRuleUpdateParamsActionsHostHeaderOverride struct{…}` - `ID PageRuleUpdateParamsActionsHostHeaderOverrideID` Apply a specific host header. - `const PageRuleUpdateParamsActionsHostHeaderOverrideIDHostHeaderOverride PageRuleUpdateParamsActionsHostHeaderOverrideID = "host_header_override"` - `Value string` The hostname to use in the `Host` header - `type IPGeolocation struct{…}` - `ID IPGeolocationID` Cloudflare adds a CF-IPCountry HTTP header containing the country code that corresponds to the visitor. - `const IPGeolocationIDIPGeolocation IPGeolocationID = "ip_geolocation"` - `Value IPGeolocationValue` The status of adding the IP Geolocation Header. - `const IPGeolocationValueOn IPGeolocationValue = "on"` - `const IPGeolocationValueOff IPGeolocationValue = "off"` - `type Mirage struct{…}` - `ID MirageID` Cloudflare Mirage reduces bandwidth used by images in mobile browsers. It can accelerate loading of image-heavy websites on very slow mobile connections and HTTP/1. - `const MirageIDMirage MirageID = "mirage"` - `Value MirageValue` The status of Mirage. - `const MirageValueOn MirageValue = "on"` - `const MirageValueOff MirageValue = "off"` - `type OpportunisticEncryption struct{…}` - `ID OpportunisticEncryptionID` Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted TLS channel. It's not a substitute for HTTPS, but provides additional security for otherwise vulnerable requests. - `const OpportunisticEncryptionIDOpportunisticEncryption OpportunisticEncryptionID = "opportunistic_encryption"` - `Value OpportunisticEncryptionValue` The status of Opportunistic Encryption. - `const OpportunisticEncryptionValueOn OpportunisticEncryptionValue = "on"` - `const OpportunisticEncryptionValueOff OpportunisticEncryptionValue = "off"` - `type OriginErrorPagePassThru struct{…}` - `ID OriginErrorPagePassThruID` Turn on or off Cloudflare error pages generated from issues sent from the origin server. If enabled, this setting triggers error pages issued by the origin. - `const OriginErrorPagePassThruIDOriginErrorPagePassThru OriginErrorPagePassThruID = "origin_error_page_pass_thru"` - `Value OriginErrorPagePassThruValue` The status of Origin Error Page Passthru. - `const OriginErrorPagePassThruValueOn OriginErrorPagePassThruValue = "on"` - `const OriginErrorPagePassThruValueOff OriginErrorPagePassThruValue = "off"` - `type Polish struct{…}` - `ID PolishID` Apply options from the Polish feature of the Cloudflare Speed app. - `const PolishIDPolish PolishID = "polish"` - `Value PolishValue` The level of Polish you want applied to your origin. - `const PolishValueOff PolishValue = "off"` - `const PolishValueLossless PolishValue = "lossless"` - `const PolishValueLossy PolishValue = "lossy"` - `type PageRuleUpdateParamsActionsResolveOverride struct{…}` - `ID PageRuleUpdateParamsActionsResolveOverrideID` Change the origin address to the value specified in this setting. - `const PageRuleUpdateParamsActionsResolveOverrideIDResolveOverride PageRuleUpdateParamsActionsResolveOverrideID = "resolve_override"` - `Value string` The origin address you want to override with. - `type PageRuleUpdateParamsActionsRespectStrongEtag struct{…}` - `ID PageRuleUpdateParamsActionsRespectStrongEtagID` Turn on or off byte-for-byte equivalency checks between the Cloudflare cache and the origin server. - `const PageRuleUpdateParamsActionsRespectStrongEtagIDRespectStrongEtag PageRuleUpdateParamsActionsRespectStrongEtagID = "respect_strong_etag"` - `Value PageRuleUpdateParamsActionsRespectStrongEtagValue` The status of Respect Strong ETags - `const PageRuleUpdateParamsActionsRespectStrongEtagValueOn PageRuleUpdateParamsActionsRespectStrongEtagValue = "on"` - `const PageRuleUpdateParamsActionsRespectStrongEtagValueOff PageRuleUpdateParamsActionsRespectStrongEtagValue = "off"` - `type ResponseBuffering struct{…}` - `ID ResponseBufferingID` Turn on or off whether Cloudflare should wait for an entire file from the origin server before forwarding it to the site visitor. By default, Cloudflare sends packets to the client as they arrive from the origin server. - `const ResponseBufferingIDResponseBuffering ResponseBufferingID = "response_buffering"` - `Value ResponseBufferingValue` The status of Response Buffering - `const ResponseBufferingValueOn ResponseBufferingValue = "on"` - `const ResponseBufferingValueOff ResponseBufferingValue = "off"` - `type RocketLoader struct{…}` - `ID RocketLoaderID` Turn on or off Rocket Loader in the Cloudflare Speed app. - `const RocketLoaderIDRocketLoader RocketLoaderID = "rocket_loader"` - `Value RocketLoaderValue` The status of Rocket Loader - `const RocketLoaderValueOn RocketLoaderValue = "on"` - `const RocketLoaderValueOff RocketLoaderValue = "off"` - `type SecurityLevel struct{…}` - `ID SecurityLevelID` Control options for the **Security Level** feature from the **Security** app. - `const SecurityLevelIDSecurityLevel SecurityLevelID = "security_level"` - `Value SecurityLevelValue` - `const SecurityLevelValueOff SecurityLevelValue = "off"` - `const SecurityLevelValueEssentiallyOff SecurityLevelValue = "essentially_off"` - `const SecurityLevelValueLow SecurityLevelValue = "low"` - `const SecurityLevelValueMedium SecurityLevelValue = "medium"` - `const SecurityLevelValueHigh SecurityLevelValue = "high"` - `const SecurityLevelValueUnderAttack SecurityLevelValue = "under_attack"` - `type SortQueryStringForCache struct{…}` - `ID SortQueryStringForCacheID` Turn on or off the reordering of query strings. When query strings have the same structure, caching improves. - `const SortQueryStringForCacheIDSortQueryStringForCache SortQueryStringForCacheID = "sort_query_string_for_cache"` - `Value SortQueryStringForCacheValue` The status of Query String Sort - `const SortQueryStringForCacheValueOn SortQueryStringForCacheValue = "on"` - `const SortQueryStringForCacheValueOff SortQueryStringForCacheValue = "off"` - `type SSL struct{…}` - `ID SSLID` Control options for the SSL feature of the Edge Certificates tab in the Cloudflare SSL/TLS app. - `const SSLIDSSL SSLID = "ssl"` - `Value SSLValue` The encryption mode that Cloudflare uses to connect to your origin server. - `const SSLValueOff SSLValue = "off"` - `const SSLValueFlexible SSLValue = "flexible"` - `const SSLValueFull SSLValue = "full"` - `const SSLValueStrict SSLValue = "strict"` - `const SSLValueOriginPull SSLValue = "origin_pull"` - `type TrueClientIPHeader struct{…}` - `ID TrueClientIPHeaderID` Turn on or off the True-Client-IP Header feature of the Cloudflare Network app. - `const TrueClientIPHeaderIDTrueClientIPHeader TrueClientIPHeaderID = "true_client_ip_header"` - `Value TrueClientIPHeaderValue` The status of True Client IP Header. - `const TrueClientIPHeaderValueOn TrueClientIPHeaderValue = "on"` - `const TrueClientIPHeaderValueOff TrueClientIPHeaderValue = "off"` - `type WAF struct{…}` - `ID WAFID` Turn on or off [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). You cannot enable or disable individual WAF managed rules via Page Rules. - `const WAFIDWAF WAFID = "waf"` - `Value WAFValue` The status of WAF managed rules (previous version). - `const WAFValueOn WAFValue = "on"` - `const WAFValueOff WAFValue = "off"` - `Targets param.Field[[]Target]` Body param: The rule targets to evaluate on each request. - `Constraint TargetConstraint` String constraint. - `Operator TargetConstraintOperator` The matches operator can use asterisks and pipes as wildcard and 'or' operators. - `const TargetConstraintOperatorMatches TargetConstraintOperator = "matches"` - `const TargetConstraintOperatorContains TargetConstraintOperator = "contains"` - `const TargetConstraintOperatorEquals TargetConstraintOperator = "equals"` - `const TargetConstraintOperatorNotEqual TargetConstraintOperator = "not_equal"` - `const TargetConstraintOperatorNotContain TargetConstraintOperator = "not_contain"` - `Value string` The URL pattern to match against the current request. The pattern may contain up to four asterisks ('*') as placeholders. - `Target TargetTarget` A target based on the URL of the request. - `const TargetTargetURL TargetTarget = "url"` - `Priority param.Field[int64]` Body param: The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: `/images/*`) but want a more specific Page Rule to take precedence (rule B: `/images/special/*`), specify a higher priority for rule B so it overrides rule A. - `Status param.Field[PageRuleUpdateParamsStatus]` Body param: The status of the Page Rule. - `const PageRuleUpdateParamsStatusActive PageRuleUpdateParamsStatus = "active"` - `const PageRuleUpdateParamsStatusDisabled PageRuleUpdateParamsStatus = "disabled"` ### Returns - `type PageRule struct{…}` - `ID string` Identifier. - `Actions []PageRuleAction` The set of actions to perform if the targets of this rule match the request. Actions can redirect to another URL or override settings, but not both. - `type AlwaysUseHTTPS struct{…}` - `ID AlwaysUseHTTPSID` If enabled, any `http://`` URL is converted to`https://` through a 301 redirect. - `const AlwaysUseHTTPSIDAlwaysUseHTTPS AlwaysUseHTTPSID = "always_use_https"` - `type AutomaticHTTPSRewrites struct{…}` - `ID AutomaticHTTPSRewritesID` Turn on or off Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesIDAutomaticHTTPSRewrites AutomaticHTTPSRewritesID = "automatic_https_rewrites"` - `Value AutomaticHTTPSRewritesValue` The status of Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesValueOn AutomaticHTTPSRewritesValue = "on"` - `const AutomaticHTTPSRewritesValueOff AutomaticHTTPSRewritesValue = "off"` - `type BrowserCacheTTL struct{…}` - `ID BrowserCacheTTLID` Control how long resources cached by client browsers remain valid. - `const BrowserCacheTTLIDBrowserCacheTTL BrowserCacheTTLID = "browser_cache_ttl"` - `Value int64` The number of seconds to cache resources for. Setting this to 0 enables "Respect Existing Headers". - `type BrowserCheck struct{…}` - `ID BrowserCheckID` Inspect the visitor's browser for headers commonly associated with spammers and certain bots. - `const BrowserCheckIDBrowserCheck BrowserCheckID = "browser_check"` - `Value BrowserCheckValue` The status of Browser Integrity Check. - `const BrowserCheckValueOn BrowserCheckValue = "on"` - `const BrowserCheckValueOff BrowserCheckValue = "off"` - `type PageRuleActionsBypassCacheOnCookie struct{…}` - `ID PageRuleActionsBypassCacheOnCookieID` Bypass cache and fetch resources from the origin server if a regular expression matches against a cookie name present in the request. - `const PageRuleActionsBypassCacheOnCookieIDBypassCacheOnCookie PageRuleActionsBypassCacheOnCookieID = "bypass_cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. Refer to [Bypass Cache on Cookie setting](https://developers.cloudflare.com/rules/page-rules/reference/additional-reference/#bypass-cache-on-cookie-setting) to learn about limited regular expression support. - `type PageRuleActionsCacheByDeviceType struct{…}` - `ID PageRuleActionsCacheByDeviceTypeID` Separate cached content based on the visitor's device type. - `const PageRuleActionsCacheByDeviceTypeIDCacheByDeviceType PageRuleActionsCacheByDeviceTypeID = "cache_by_device_type"` - `Value PageRuleActionsCacheByDeviceTypeValue` The status of Cache By Device Type. - `const PageRuleActionsCacheByDeviceTypeValueOn PageRuleActionsCacheByDeviceTypeValue = "on"` - `const PageRuleActionsCacheByDeviceTypeValueOff PageRuleActionsCacheByDeviceTypeValue = "off"` - `type PageRuleActionsCacheDeceptionArmor struct{…}` - `ID PageRuleActionsCacheDeceptionArmorID` Protect from web cache deception attacks while still allowing static assets to be cached. This setting verifies that the URL's extension matches the returned `Content-Type`. - `const PageRuleActionsCacheDeceptionArmorIDCacheDeceptionArmor PageRuleActionsCacheDeceptionArmorID = "cache_deception_armor"` - `Value PageRuleActionsCacheDeceptionArmorValue` The status of Cache Deception Armor. - `const PageRuleActionsCacheDeceptionArmorValueOn PageRuleActionsCacheDeceptionArmorValue = "on"` - `const PageRuleActionsCacheDeceptionArmorValueOff PageRuleActionsCacheDeceptionArmorValue = "off"` - `type PageRuleActionsCacheKeyFields struct{…}` - `ID PageRuleActionsCacheKeyFieldsID` Control specifically what variables to include when deciding which resources to cache. This allows customers to determine what to cache based on something other than just the URL. - `const PageRuleActionsCacheKeyFieldsIDCacheKeyFields PageRuleActionsCacheKeyFieldsID = "cache_key_fields"` - `Value PageRuleActionsCacheKeyFieldsValue` - `Cookie PageRuleActionsCacheKeyFieldsValueCookie` Controls which cookies appear in the Cache Key. - `CheckPresence []string` A list of cookies to check for the presence of, without including their actual values. - `Include []string` A list of cookies to include. - `Header PageRuleActionsCacheKeyFieldsValueHeader` Controls which headers go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `CheckPresence []string` A list of headers to check for the presence of, without including their actual values. - `Exclude []string` A list of headers to ignore. - `Include []string` A list of headers to include. - `Host PageRuleActionsCacheKeyFieldsValueHost` Determines which host header to include in the Cache Key. - `Resolved bool` Whether to include the Host header in the HTTP request sent to the origin. - `QueryString PageRuleActionsCacheKeyFieldsValueQueryString` Controls which URL query string parameters go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `Exclude PageRuleActionsCacheKeyFieldsValueQueryStringExcludeUnion` Ignore all query string parameters. - `type PageRuleActionsCacheKeyFieldsValueQueryStringExcludeString string` Ignore all query string parameters. - `const PageRuleActionsCacheKeyFieldsValueQueryStringExcludeStringStar PageRuleActionsCacheKeyFieldsValueQueryStringExcludeString = "*"` - `type PageRuleActionsCacheKeyFieldsValueQueryStringExcludeArray []string` A list of query string parameters to ignore. - `Include PageRuleActionsCacheKeyFieldsValueQueryStringIncludeUnion` Include all query string parameters. - `type PageRuleActionsCacheKeyFieldsValueQueryStringIncludeString string` Include all query string parameters. - `const PageRuleActionsCacheKeyFieldsValueQueryStringIncludeStringStar PageRuleActionsCacheKeyFieldsValueQueryStringIncludeString = "*"` - `type PageRuleActionsCacheKeyFieldsValueQueryStringIncludeArray []string` A list of query string parameters to include. - `User PageRuleActionsCacheKeyFieldsValueUser` Feature fields to add features about the end-user (client) into the Cache Key. - `DeviceType bool` Classifies a request as `mobile`, `desktop`, or `tablet` based on the User Agent. - `Geo bool` Includes the client's country, derived from the IP address. - `Lang bool` Includes the first language code contained in the `Accept-Language` header sent by the client. - `type CacheLevel struct{…}` - `ID CacheLevelID` Apply custom caching based on the option selected. - `const CacheLevelIDCacheLevel CacheLevelID = "cache_level"` - `Value CacheLevelValue` * `bypass`: Cloudflare does not cache. * `basic`: Delivers resources from cache when there is no query string. * `simplified`: Delivers the same resource to everyone independent of the query string. * `aggressive`: Caches all static content that has a query string. * `cache_everything`: Treats all content as static and caches all file types beyond the [Cloudflare default cached content](https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#default-cached-file-extensions). - `const CacheLevelValueBypass CacheLevelValue = "bypass"` - `const CacheLevelValueBasic CacheLevelValue = "basic"` - `const CacheLevelValueSimplified CacheLevelValue = "simplified"` - `const CacheLevelValueAggressive CacheLevelValue = "aggressive"` - `const CacheLevelValueCacheEverything CacheLevelValue = "cache_everything"` - `type PageRuleActionsCacheOnCookie struct{…}` - `ID PageRuleActionsCacheOnCookieID` Apply the Cache Everything option (Cache Level setting) based on a regular expression match against a cookie name. - `const PageRuleActionsCacheOnCookieIDCacheOnCookie PageRuleActionsCacheOnCookieID = "cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. - `type PageRuleActionsCacheTTLByStatus struct{…}` - `ID PageRuleActionsCacheTTLByStatusID` Enterprise customers can set cache time-to-live (TTL) based on the response status from the origin web server. Cache TTL refers to the duration of a resource in the Cloudflare network before being marked as stale or discarded from cache. Status codes are returned by a resource's origin. Setting cache TTL based on response status overrides the default cache behavior (standard caching) for static files and overrides cache instructions sent by the origin web server. To cache non-static assets, set a Cache Level of Cache Everything using a Page Rule. Setting no-store Cache-Control or a low TTL (using `max-age`/`s-maxage`) increases requests to origin web servers and decreases performance. - `const PageRuleActionsCacheTTLByStatusIDCacheTTLByStatus PageRuleActionsCacheTTLByStatusID = "cache_ttl_by_status"` - `Value map[string, PageRuleActionsCacheTTLByStatusValueUnion]` A JSON object containing status codes and their corresponding TTLs. Each key-value pair in the cache TTL by status cache rule has the following syntax - `status_code`: An integer value such as 200 or 500. status_code matches the exact status code from the origin web server. Valid status codes are between 100-999. - `status_code_range`: Integer values for from and to. status_code_range matches any status code from the origin web server within the specified range. - `value`: An integer value that defines the duration an asset is valid in seconds or one of the following strings: no-store (equivalent to -1), no-cache (equivalent to 0). - `type PageRuleActionsCacheTTLByStatusValueString string` `no-store` (equivalent to -1), `no-cache` (equivalent to 0) - `const PageRuleActionsCacheTTLByStatusValueStringNoCache PageRuleActionsCacheTTLByStatusValueString = "no-cache"` - `const PageRuleActionsCacheTTLByStatusValueStringNoStore PageRuleActionsCacheTTLByStatusValueString = "no-store"` - `UnionInt` - `type PageRuleActionsDisableApps struct{…}` - `ID PageRuleActionsDisableAppsID` Turn off all active [Cloudflare Apps](https://developers.cloudflare.com/support/more-dashboard-apps/cloudflare-apps/) (deprecated). - `const PageRuleActionsDisableAppsIDDisableApps PageRuleActionsDisableAppsID = "disable_apps"` - `type PageRuleActionsDisablePerformance struct{…}` - `ID PageRuleActionsDisablePerformanceID` Turn off [Rocket Loader](https://developers.cloudflare.com/speed/optimization/content/rocket-loader/), and [Polish](https://developers.cloudflare.com/images/polish/). - `const PageRuleActionsDisablePerformanceIDDisablePerformance PageRuleActionsDisablePerformanceID = "disable_performance"` - `type PageRuleActionsDisableSecurity struct{…}` - `ID PageRuleActionsDisableSecurityID` Turn off [Email Obfuscation](https://developers.cloudflare.com/waf/tools/scrape-shield/email-address-obfuscation/), [Rate Limiting (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/), [Scrape Shield](https://developers.cloudflare.com/waf/tools/scrape-shield/), [URL (Zone) Lockdown](https://developers.cloudflare.com/waf/tools/zone-lockdown/), and [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). - `const PageRuleActionsDisableSecurityIDDisableSecurity PageRuleActionsDisableSecurityID = "disable_security"` - `type PageRuleActionsDisableZaraz struct{…}` - `ID PageRuleActionsDisableZarazID` Turn off [Zaraz](https://developers.cloudflare.com/zaraz/). - `const PageRuleActionsDisableZarazIDDisableZaraz PageRuleActionsDisableZarazID = "disable_zaraz"` - `type PageRuleActionsEdgeCacheTTL struct{…}` - `ID PageRuleActionsEdgeCacheTTLID` Specify how long to cache a resource in the Cloudflare global network. *Edge Cache TTL* is not visible in response headers. - `const PageRuleActionsEdgeCacheTTLIDEdgeCacheTTL PageRuleActionsEdgeCacheTTLID = "edge_cache_ttl"` - `Value int64` - `type EmailObfuscation struct{…}` - `ID EmailObfuscationID` Turn on or off **Email Obfuscation**. - `const EmailObfuscationIDEmailObfuscation EmailObfuscationID = "email_obfuscation"` - `Value EmailObfuscationValue` The status of Email Obfuscation. - `const EmailObfuscationValueOn EmailObfuscationValue = "on"` - `const EmailObfuscationValueOff EmailObfuscationValue = "off"` - `type PageRuleActionsExplicitCacheControl struct{…}` - `ID PageRuleActionsExplicitCacheControlID` Origin Cache Control is enabled by default for Free, Pro, and Business domains and disabled by default for Enterprise domains. - `const PageRuleActionsExplicitCacheControlIDExplicitCacheControl PageRuleActionsExplicitCacheControlID = "explicit_cache_control"` - `Value PageRuleActionsExplicitCacheControlValue` The status of Origin Cache Control. - `const PageRuleActionsExplicitCacheControlValueOn PageRuleActionsExplicitCacheControlValue = "on"` - `const PageRuleActionsExplicitCacheControlValueOff PageRuleActionsExplicitCacheControlValue = "off"` - `type PageRuleActionsForwardingURL struct{…}` - `ID PageRuleActionsForwardingURLID` Redirects one URL to another using an `HTTP 301/302` redirect. Refer to [Wildcard matching and referencing](https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/). - `const PageRuleActionsForwardingURLIDForwardingURL PageRuleActionsForwardingURLID = "forwarding_url"` - `Value PageRuleActionsForwardingURLValue` - `StatusCode PageRuleActionsForwardingURLValueStatusCode` The status code to use for the URL redirect. 301 is a permanent redirect. 302 is a temporary redirect. - `const PageRuleActionsForwardingURLValueStatusCode301 PageRuleActionsForwardingURLValueStatusCode = 301` - `const PageRuleActionsForwardingURLValueStatusCode302 PageRuleActionsForwardingURLValueStatusCode = 302` - `URL string` The URL to redirect the request to. Notes: ${num} refers to the position of '*' in the constraint value. - `type PageRuleActionsHostHeaderOverride struct{…}` - `ID PageRuleActionsHostHeaderOverrideID` Apply a specific host header. - `const PageRuleActionsHostHeaderOverrideIDHostHeaderOverride PageRuleActionsHostHeaderOverrideID = "host_header_override"` - `Value string` The hostname to use in the `Host` header - `type IPGeolocation struct{…}` - `ID IPGeolocationID` Cloudflare adds a CF-IPCountry HTTP header containing the country code that corresponds to the visitor. - `const IPGeolocationIDIPGeolocation IPGeolocationID = "ip_geolocation"` - `Value IPGeolocationValue` The status of adding the IP Geolocation Header. - `const IPGeolocationValueOn IPGeolocationValue = "on"` - `const IPGeolocationValueOff IPGeolocationValue = "off"` - `type Mirage struct{…}` - `ID MirageID` Cloudflare Mirage reduces bandwidth used by images in mobile browsers. It can accelerate loading of image-heavy websites on very slow mobile connections and HTTP/1. - `const MirageIDMirage MirageID = "mirage"` - `Value MirageValue` The status of Mirage. - `const MirageValueOn MirageValue = "on"` - `const MirageValueOff MirageValue = "off"` - `type OpportunisticEncryption struct{…}` - `ID OpportunisticEncryptionID` Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted TLS channel. It's not a substitute for HTTPS, but provides additional security for otherwise vulnerable requests. - `const OpportunisticEncryptionIDOpportunisticEncryption OpportunisticEncryptionID = "opportunistic_encryption"` - `Value OpportunisticEncryptionValue` The status of Opportunistic Encryption. - `const OpportunisticEncryptionValueOn OpportunisticEncryptionValue = "on"` - `const OpportunisticEncryptionValueOff OpportunisticEncryptionValue = "off"` - `type OriginErrorPagePassThru struct{…}` - `ID OriginErrorPagePassThruID` Turn on or off Cloudflare error pages generated from issues sent from the origin server. If enabled, this setting triggers error pages issued by the origin. - `const OriginErrorPagePassThruIDOriginErrorPagePassThru OriginErrorPagePassThruID = "origin_error_page_pass_thru"` - `Value OriginErrorPagePassThruValue` The status of Origin Error Page Passthru. - `const OriginErrorPagePassThruValueOn OriginErrorPagePassThruValue = "on"` - `const OriginErrorPagePassThruValueOff OriginErrorPagePassThruValue = "off"` - `type Polish struct{…}` - `ID PolishID` Apply options from the Polish feature of the Cloudflare Speed app. - `const PolishIDPolish PolishID = "polish"` - `Value PolishValue` The level of Polish you want applied to your origin. - `const PolishValueOff PolishValue = "off"` - `const PolishValueLossless PolishValue = "lossless"` - `const PolishValueLossy PolishValue = "lossy"` - `type PageRuleActionsResolveOverride struct{…}` - `ID PageRuleActionsResolveOverrideID` Change the origin address to the value specified in this setting. - `const PageRuleActionsResolveOverrideIDResolveOverride PageRuleActionsResolveOverrideID = "resolve_override"` - `Value string` The origin address you want to override with. - `type PageRuleActionsRespectStrongEtag struct{…}` - `ID PageRuleActionsRespectStrongEtagID` Turn on or off byte-for-byte equivalency checks between the Cloudflare cache and the origin server. - `const PageRuleActionsRespectStrongEtagIDRespectStrongEtag PageRuleActionsRespectStrongEtagID = "respect_strong_etag"` - `Value PageRuleActionsRespectStrongEtagValue` The status of Respect Strong ETags - `const PageRuleActionsRespectStrongEtagValueOn PageRuleActionsRespectStrongEtagValue = "on"` - `const PageRuleActionsRespectStrongEtagValueOff PageRuleActionsRespectStrongEtagValue = "off"` - `type ResponseBuffering struct{…}` - `ID ResponseBufferingID` Turn on or off whether Cloudflare should wait for an entire file from the origin server before forwarding it to the site visitor. By default, Cloudflare sends packets to the client as they arrive from the origin server. - `const ResponseBufferingIDResponseBuffering ResponseBufferingID = "response_buffering"` - `Value ResponseBufferingValue` The status of Response Buffering - `const ResponseBufferingValueOn ResponseBufferingValue = "on"` - `const ResponseBufferingValueOff ResponseBufferingValue = "off"` - `type RocketLoader struct{…}` - `ID RocketLoaderID` Turn on or off Rocket Loader in the Cloudflare Speed app. - `const RocketLoaderIDRocketLoader RocketLoaderID = "rocket_loader"` - `Value RocketLoaderValue` The status of Rocket Loader - `const RocketLoaderValueOn RocketLoaderValue = "on"` - `const RocketLoaderValueOff RocketLoaderValue = "off"` - `type SecurityLevel struct{…}` - `ID SecurityLevelID` Control options for the **Security Level** feature from the **Security** app. - `const SecurityLevelIDSecurityLevel SecurityLevelID = "security_level"` - `Value SecurityLevelValue` - `const SecurityLevelValueOff SecurityLevelValue = "off"` - `const SecurityLevelValueEssentiallyOff SecurityLevelValue = "essentially_off"` - `const SecurityLevelValueLow SecurityLevelValue = "low"` - `const SecurityLevelValueMedium SecurityLevelValue = "medium"` - `const SecurityLevelValueHigh SecurityLevelValue = "high"` - `const SecurityLevelValueUnderAttack SecurityLevelValue = "under_attack"` - `type SortQueryStringForCache struct{…}` - `ID SortQueryStringForCacheID` Turn on or off the reordering of query strings. When query strings have the same structure, caching improves. - `const SortQueryStringForCacheIDSortQueryStringForCache SortQueryStringForCacheID = "sort_query_string_for_cache"` - `Value SortQueryStringForCacheValue` The status of Query String Sort - `const SortQueryStringForCacheValueOn SortQueryStringForCacheValue = "on"` - `const SortQueryStringForCacheValueOff SortQueryStringForCacheValue = "off"` - `type SSL struct{…}` - `ID SSLID` Control options for the SSL feature of the Edge Certificates tab in the Cloudflare SSL/TLS app. - `const SSLIDSSL SSLID = "ssl"` - `Value SSLValue` The encryption mode that Cloudflare uses to connect to your origin server. - `const SSLValueOff SSLValue = "off"` - `const SSLValueFlexible SSLValue = "flexible"` - `const SSLValueFull SSLValue = "full"` - `const SSLValueStrict SSLValue = "strict"` - `const SSLValueOriginPull SSLValue = "origin_pull"` - `type TrueClientIPHeader struct{…}` - `ID TrueClientIPHeaderID` Turn on or off the True-Client-IP Header feature of the Cloudflare Network app. - `const TrueClientIPHeaderIDTrueClientIPHeader TrueClientIPHeaderID = "true_client_ip_header"` - `Value TrueClientIPHeaderValue` The status of True Client IP Header. - `const TrueClientIPHeaderValueOn TrueClientIPHeaderValue = "on"` - `const TrueClientIPHeaderValueOff TrueClientIPHeaderValue = "off"` - `type WAF struct{…}` - `ID WAFID` Turn on or off [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). You cannot enable or disable individual WAF managed rules via Page Rules. - `const WAFIDWAF WAFID = "waf"` - `Value WAFValue` The status of WAF managed rules (previous version). - `const WAFValueOn WAFValue = "on"` - `const WAFValueOff WAFValue = "off"` - `CreatedOn Time` The timestamp of when the Page Rule was created. - `ModifiedOn Time` The timestamp of when the Page Rule was last modified. - `Priority int64` The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: `/images/*`) but want a more specific Page Rule to take precedence (rule B: `/images/special/*`), specify a higher priority for rule B so it overrides rule A. - `Status PageRuleStatus` The status of the Page Rule. - `const PageRuleStatusActive PageRuleStatus = "active"` - `const PageRuleStatusDisabled PageRuleStatus = "disabled"` - `Targets []Target` The rule targets to evaluate on each request. - `Constraint TargetConstraint` String constraint. - `Operator TargetConstraintOperator` The matches operator can use asterisks and pipes as wildcard and 'or' operators. - `const TargetConstraintOperatorMatches TargetConstraintOperator = "matches"` - `const TargetConstraintOperatorContains TargetConstraintOperator = "contains"` - `const TargetConstraintOperatorEquals TargetConstraintOperator = "equals"` - `const TargetConstraintOperatorNotEqual TargetConstraintOperator = "not_equal"` - `const TargetConstraintOperatorNotContain TargetConstraintOperator = "not_contain"` - `Value string` The URL pattern to match against the current request. The pattern may contain up to four asterisks ('*') as placeholders. - `Target TargetTarget` A target based on the URL of the request. - `const TargetTargetURL TargetTarget = "url"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/page_rules" "github.com/cloudflare/cloudflare-go/zones" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) pageRule, err := client.PageRules.Update( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", page_rules.PageRuleUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Actions: cloudflare.F([]page_rules.PageRuleUpdateParamsActionUnion{zones.BrowserCheckParam{ ID: cloudflare.F(zones.BrowserCheckIDBrowserCheck), }}), Targets: cloudflare.F([]page_rules.TargetParam{page_rules.TargetParam{ Constraint: cloudflare.F(page_rules.TargetConstraintParam{ Operator: cloudflare.F(page_rules.TargetConstraintOperatorMatches), Value: cloudflare.F("*example.com/images/*"), }), Target: cloudflare.F(page_rules.TargetTargetURL), }}), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", pageRule.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353", "actions": [ { "id": "browser_check", "value": "on" } ], "created_on": "2014-01-01T05:20:00.12345Z", "modified_on": "2014-01-01T05:20:00.12345Z", "priority": 0, "status": "active", "targets": [ { "constraint": { "operator": "matches", "value": "*example.com/images/*" }, "target": "url" } ] } } ``` ## Edit a Page Rule `client.PageRules.Edit(ctx, pageruleID, params) (*PageRule, error)` **patch** `/zones/{zone_id}/pagerules/{pagerule_id}` Updates one or more fields of an existing Page Rule. ### Parameters - `pageruleID string` Identifier. - `params PageRuleEditParams` - `ZoneID param.Field[string]` Path param: Identifier. - `Actions param.Field[[]PageRuleEditParamsAction]` Body param: The set of actions to perform if the targets of this rule match the request. Actions can redirect to another URL or override settings, but not both. - `type AlwaysUseHTTPS struct{…}` - `ID AlwaysUseHTTPSID` If enabled, any `http://`` URL is converted to`https://` through a 301 redirect. - `const AlwaysUseHTTPSIDAlwaysUseHTTPS AlwaysUseHTTPSID = "always_use_https"` - `type AutomaticHTTPSRewrites struct{…}` - `ID AutomaticHTTPSRewritesID` Turn on or off Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesIDAutomaticHTTPSRewrites AutomaticHTTPSRewritesID = "automatic_https_rewrites"` - `Value AutomaticHTTPSRewritesValue` The status of Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesValueOn AutomaticHTTPSRewritesValue = "on"` - `const AutomaticHTTPSRewritesValueOff AutomaticHTTPSRewritesValue = "off"` - `type BrowserCacheTTL struct{…}` - `ID BrowserCacheTTLID` Control how long resources cached by client browsers remain valid. - `const BrowserCacheTTLIDBrowserCacheTTL BrowserCacheTTLID = "browser_cache_ttl"` - `Value int64` The number of seconds to cache resources for. Setting this to 0 enables "Respect Existing Headers". - `type BrowserCheck struct{…}` - `ID BrowserCheckID` Inspect the visitor's browser for headers commonly associated with spammers and certain bots. - `const BrowserCheckIDBrowserCheck BrowserCheckID = "browser_check"` - `Value BrowserCheckValue` The status of Browser Integrity Check. - `const BrowserCheckValueOn BrowserCheckValue = "on"` - `const BrowserCheckValueOff BrowserCheckValue = "off"` - `type PageRuleEditParamsActionsBypassCacheOnCookie struct{…}` - `ID PageRuleEditParamsActionsBypassCacheOnCookieID` Bypass cache and fetch resources from the origin server if a regular expression matches against a cookie name present in the request. - `const PageRuleEditParamsActionsBypassCacheOnCookieIDBypassCacheOnCookie PageRuleEditParamsActionsBypassCacheOnCookieID = "bypass_cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. Refer to [Bypass Cache on Cookie setting](https://developers.cloudflare.com/rules/page-rules/reference/additional-reference/#bypass-cache-on-cookie-setting) to learn about limited regular expression support. - `type PageRuleEditParamsActionsCacheByDeviceType struct{…}` - `ID PageRuleEditParamsActionsCacheByDeviceTypeID` Separate cached content based on the visitor's device type. - `const PageRuleEditParamsActionsCacheByDeviceTypeIDCacheByDeviceType PageRuleEditParamsActionsCacheByDeviceTypeID = "cache_by_device_type"` - `Value PageRuleEditParamsActionsCacheByDeviceTypeValue` The status of Cache By Device Type. - `const PageRuleEditParamsActionsCacheByDeviceTypeValueOn PageRuleEditParamsActionsCacheByDeviceTypeValue = "on"` - `const PageRuleEditParamsActionsCacheByDeviceTypeValueOff PageRuleEditParamsActionsCacheByDeviceTypeValue = "off"` - `type PageRuleEditParamsActionsCacheDeceptionArmor struct{…}` - `ID PageRuleEditParamsActionsCacheDeceptionArmorID` Protect from web cache deception attacks while still allowing static assets to be cached. This setting verifies that the URL's extension matches the returned `Content-Type`. - `const PageRuleEditParamsActionsCacheDeceptionArmorIDCacheDeceptionArmor PageRuleEditParamsActionsCacheDeceptionArmorID = "cache_deception_armor"` - `Value PageRuleEditParamsActionsCacheDeceptionArmorValue` The status of Cache Deception Armor. - `const PageRuleEditParamsActionsCacheDeceptionArmorValueOn PageRuleEditParamsActionsCacheDeceptionArmorValue = "on"` - `const PageRuleEditParamsActionsCacheDeceptionArmorValueOff PageRuleEditParamsActionsCacheDeceptionArmorValue = "off"` - `type PageRuleEditParamsActionsCacheKeyFields struct{…}` - `ID PageRuleEditParamsActionsCacheKeyFieldsID` Control specifically what variables to include when deciding which resources to cache. This allows customers to determine what to cache based on something other than just the URL. - `const PageRuleEditParamsActionsCacheKeyFieldsIDCacheKeyFields PageRuleEditParamsActionsCacheKeyFieldsID = "cache_key_fields"` - `Value PageRuleEditParamsActionsCacheKeyFieldsValue` - `Cookie PageRuleEditParamsActionsCacheKeyFieldsValueCookie` Controls which cookies appear in the Cache Key. - `CheckPresence []string` A list of cookies to check for the presence of, without including their actual values. - `Include []string` A list of cookies to include. - `Header PageRuleEditParamsActionsCacheKeyFieldsValueHeader` Controls which headers go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `CheckPresence []string` A list of headers to check for the presence of, without including their actual values. - `Exclude []string` A list of headers to ignore. - `Include []string` A list of headers to include. - `Host PageRuleEditParamsActionsCacheKeyFieldsValueHost` Determines which host header to include in the Cache Key. - `Resolved bool` Whether to include the Host header in the HTTP request sent to the origin. - `QueryString PageRuleEditParamsActionsCacheKeyFieldsValueQueryString` Controls which URL query string parameters go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `Exclude PageRuleEditParamsActionsCacheKeyFieldsValueQueryStringExcludeUnion` Ignore all query string parameters. - `type PageRuleEditParamsActionsCacheKeyFieldsValueQueryStringExcludeString string` Ignore all query string parameters. - `const PageRuleEditParamsActionsCacheKeyFieldsValueQueryStringExcludeStringStar PageRuleEditParamsActionsCacheKeyFieldsValueQueryStringExcludeString = "*"` - `type PageRuleEditParamsActionsCacheKeyFieldsValueQueryStringExcludeArray []string` A list of query string parameters to ignore. - `Include PageRuleEditParamsActionsCacheKeyFieldsValueQueryStringIncludeUnion` Include all query string parameters. - `type PageRuleEditParamsActionsCacheKeyFieldsValueQueryStringIncludeString string` Include all query string parameters. - `const PageRuleEditParamsActionsCacheKeyFieldsValueQueryStringIncludeStringStar PageRuleEditParamsActionsCacheKeyFieldsValueQueryStringIncludeString = "*"` - `type PageRuleEditParamsActionsCacheKeyFieldsValueQueryStringIncludeArray []string` A list of query string parameters to include. - `User PageRuleEditParamsActionsCacheKeyFieldsValueUser` Feature fields to add features about the end-user (client) into the Cache Key. - `DeviceType bool` Classifies a request as `mobile`, `desktop`, or `tablet` based on the User Agent. - `Geo bool` Includes the client's country, derived from the IP address. - `Lang bool` Includes the first language code contained in the `Accept-Language` header sent by the client. - `type CacheLevel struct{…}` - `ID CacheLevelID` Apply custom caching based on the option selected. - `const CacheLevelIDCacheLevel CacheLevelID = "cache_level"` - `Value CacheLevelValue` * `bypass`: Cloudflare does not cache. * `basic`: Delivers resources from cache when there is no query string. * `simplified`: Delivers the same resource to everyone independent of the query string. * `aggressive`: Caches all static content that has a query string. * `cache_everything`: Treats all content as static and caches all file types beyond the [Cloudflare default cached content](https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#default-cached-file-extensions). - `const CacheLevelValueBypass CacheLevelValue = "bypass"` - `const CacheLevelValueBasic CacheLevelValue = "basic"` - `const CacheLevelValueSimplified CacheLevelValue = "simplified"` - `const CacheLevelValueAggressive CacheLevelValue = "aggressive"` - `const CacheLevelValueCacheEverything CacheLevelValue = "cache_everything"` - `type PageRuleEditParamsActionsCacheOnCookie struct{…}` - `ID PageRuleEditParamsActionsCacheOnCookieID` Apply the Cache Everything option (Cache Level setting) based on a regular expression match against a cookie name. - `const PageRuleEditParamsActionsCacheOnCookieIDCacheOnCookie PageRuleEditParamsActionsCacheOnCookieID = "cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. - `type PageRuleEditParamsActionsCacheTTLByStatus struct{…}` - `ID PageRuleEditParamsActionsCacheTTLByStatusID` Enterprise customers can set cache time-to-live (TTL) based on the response status from the origin web server. Cache TTL refers to the duration of a resource in the Cloudflare network before being marked as stale or discarded from cache. Status codes are returned by a resource's origin. Setting cache TTL based on response status overrides the default cache behavior (standard caching) for static files and overrides cache instructions sent by the origin web server. To cache non-static assets, set a Cache Level of Cache Everything using a Page Rule. Setting no-store Cache-Control or a low TTL (using `max-age`/`s-maxage`) increases requests to origin web servers and decreases performance. - `const PageRuleEditParamsActionsCacheTTLByStatusIDCacheTTLByStatus PageRuleEditParamsActionsCacheTTLByStatusID = "cache_ttl_by_status"` - `Value map[string, PageRuleEditParamsActionsCacheTTLByStatusValueUnion]` A JSON object containing status codes and their corresponding TTLs. Each key-value pair in the cache TTL by status cache rule has the following syntax - `status_code`: An integer value such as 200 or 500. status_code matches the exact status code from the origin web server. Valid status codes are between 100-999. - `status_code_range`: Integer values for from and to. status_code_range matches any status code from the origin web server within the specified range. - `value`: An integer value that defines the duration an asset is valid in seconds or one of the following strings: no-store (equivalent to -1), no-cache (equivalent to 0). - `type PageRuleEditParamsActionsCacheTTLByStatusValueString string` `no-store` (equivalent to -1), `no-cache` (equivalent to 0) - `const PageRuleEditParamsActionsCacheTTLByStatusValueStringNoCache PageRuleEditParamsActionsCacheTTLByStatusValueString = "no-cache"` - `const PageRuleEditParamsActionsCacheTTLByStatusValueStringNoStore PageRuleEditParamsActionsCacheTTLByStatusValueString = "no-store"` - `UnionInt` - `type PageRuleEditParamsActionsDisableApps struct{…}` - `ID PageRuleEditParamsActionsDisableAppsID` Turn off all active [Cloudflare Apps](https://developers.cloudflare.com/support/more-dashboard-apps/cloudflare-apps/) (deprecated). - `const PageRuleEditParamsActionsDisableAppsIDDisableApps PageRuleEditParamsActionsDisableAppsID = "disable_apps"` - `type PageRuleEditParamsActionsDisablePerformance struct{…}` - `ID PageRuleEditParamsActionsDisablePerformanceID` Turn off [Rocket Loader](https://developers.cloudflare.com/speed/optimization/content/rocket-loader/), and [Polish](https://developers.cloudflare.com/images/polish/). - `const PageRuleEditParamsActionsDisablePerformanceIDDisablePerformance PageRuleEditParamsActionsDisablePerformanceID = "disable_performance"` - `type PageRuleEditParamsActionsDisableSecurity struct{…}` - `ID PageRuleEditParamsActionsDisableSecurityID` Turn off [Email Obfuscation](https://developers.cloudflare.com/waf/tools/scrape-shield/email-address-obfuscation/), [Rate Limiting (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/), [Scrape Shield](https://developers.cloudflare.com/waf/tools/scrape-shield/), [URL (Zone) Lockdown](https://developers.cloudflare.com/waf/tools/zone-lockdown/), and [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). - `const PageRuleEditParamsActionsDisableSecurityIDDisableSecurity PageRuleEditParamsActionsDisableSecurityID = "disable_security"` - `type PageRuleEditParamsActionsDisableZaraz struct{…}` - `ID PageRuleEditParamsActionsDisableZarazID` Turn off [Zaraz](https://developers.cloudflare.com/zaraz/). - `const PageRuleEditParamsActionsDisableZarazIDDisableZaraz PageRuleEditParamsActionsDisableZarazID = "disable_zaraz"` - `type PageRuleEditParamsActionsEdgeCacheTTL struct{…}` - `ID PageRuleEditParamsActionsEdgeCacheTTLID` Specify how long to cache a resource in the Cloudflare global network. *Edge Cache TTL* is not visible in response headers. - `const PageRuleEditParamsActionsEdgeCacheTTLIDEdgeCacheTTL PageRuleEditParamsActionsEdgeCacheTTLID = "edge_cache_ttl"` - `Value int64` - `type EmailObfuscation struct{…}` - `ID EmailObfuscationID` Turn on or off **Email Obfuscation**. - `const EmailObfuscationIDEmailObfuscation EmailObfuscationID = "email_obfuscation"` - `Value EmailObfuscationValue` The status of Email Obfuscation. - `const EmailObfuscationValueOn EmailObfuscationValue = "on"` - `const EmailObfuscationValueOff EmailObfuscationValue = "off"` - `type PageRuleEditParamsActionsExplicitCacheControl struct{…}` - `ID PageRuleEditParamsActionsExplicitCacheControlID` Origin Cache Control is enabled by default for Free, Pro, and Business domains and disabled by default for Enterprise domains. - `const PageRuleEditParamsActionsExplicitCacheControlIDExplicitCacheControl PageRuleEditParamsActionsExplicitCacheControlID = "explicit_cache_control"` - `Value PageRuleEditParamsActionsExplicitCacheControlValue` The status of Origin Cache Control. - `const PageRuleEditParamsActionsExplicitCacheControlValueOn PageRuleEditParamsActionsExplicitCacheControlValue = "on"` - `const PageRuleEditParamsActionsExplicitCacheControlValueOff PageRuleEditParamsActionsExplicitCacheControlValue = "off"` - `type PageRuleEditParamsActionsForwardingURL struct{…}` - `ID PageRuleEditParamsActionsForwardingURLID` Redirects one URL to another using an `HTTP 301/302` redirect. Refer to [Wildcard matching and referencing](https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/). - `const PageRuleEditParamsActionsForwardingURLIDForwardingURL PageRuleEditParamsActionsForwardingURLID = "forwarding_url"` - `Value PageRuleEditParamsActionsForwardingURLValue` - `StatusCode PageRuleEditParamsActionsForwardingURLValueStatusCode` The status code to use for the URL redirect. 301 is a permanent redirect. 302 is a temporary redirect. - `const PageRuleEditParamsActionsForwardingURLValueStatusCode301 PageRuleEditParamsActionsForwardingURLValueStatusCode = 301` - `const PageRuleEditParamsActionsForwardingURLValueStatusCode302 PageRuleEditParamsActionsForwardingURLValueStatusCode = 302` - `URL string` The URL to redirect the request to. Notes: ${num} refers to the position of '*' in the constraint value. - `type PageRuleEditParamsActionsHostHeaderOverride struct{…}` - `ID PageRuleEditParamsActionsHostHeaderOverrideID` Apply a specific host header. - `const PageRuleEditParamsActionsHostHeaderOverrideIDHostHeaderOverride PageRuleEditParamsActionsHostHeaderOverrideID = "host_header_override"` - `Value string` The hostname to use in the `Host` header - `type IPGeolocation struct{…}` - `ID IPGeolocationID` Cloudflare adds a CF-IPCountry HTTP header containing the country code that corresponds to the visitor. - `const IPGeolocationIDIPGeolocation IPGeolocationID = "ip_geolocation"` - `Value IPGeolocationValue` The status of adding the IP Geolocation Header. - `const IPGeolocationValueOn IPGeolocationValue = "on"` - `const IPGeolocationValueOff IPGeolocationValue = "off"` - `type Mirage struct{…}` - `ID MirageID` Cloudflare Mirage reduces bandwidth used by images in mobile browsers. It can accelerate loading of image-heavy websites on very slow mobile connections and HTTP/1. - `const MirageIDMirage MirageID = "mirage"` - `Value MirageValue` The status of Mirage. - `const MirageValueOn MirageValue = "on"` - `const MirageValueOff MirageValue = "off"` - `type OpportunisticEncryption struct{…}` - `ID OpportunisticEncryptionID` Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted TLS channel. It's not a substitute for HTTPS, but provides additional security for otherwise vulnerable requests. - `const OpportunisticEncryptionIDOpportunisticEncryption OpportunisticEncryptionID = "opportunistic_encryption"` - `Value OpportunisticEncryptionValue` The status of Opportunistic Encryption. - `const OpportunisticEncryptionValueOn OpportunisticEncryptionValue = "on"` - `const OpportunisticEncryptionValueOff OpportunisticEncryptionValue = "off"` - `type OriginErrorPagePassThru struct{…}` - `ID OriginErrorPagePassThruID` Turn on or off Cloudflare error pages generated from issues sent from the origin server. If enabled, this setting triggers error pages issued by the origin. - `const OriginErrorPagePassThruIDOriginErrorPagePassThru OriginErrorPagePassThruID = "origin_error_page_pass_thru"` - `Value OriginErrorPagePassThruValue` The status of Origin Error Page Passthru. - `const OriginErrorPagePassThruValueOn OriginErrorPagePassThruValue = "on"` - `const OriginErrorPagePassThruValueOff OriginErrorPagePassThruValue = "off"` - `type Polish struct{…}` - `ID PolishID` Apply options from the Polish feature of the Cloudflare Speed app. - `const PolishIDPolish PolishID = "polish"` - `Value PolishValue` The level of Polish you want applied to your origin. - `const PolishValueOff PolishValue = "off"` - `const PolishValueLossless PolishValue = "lossless"` - `const PolishValueLossy PolishValue = "lossy"` - `type PageRuleEditParamsActionsResolveOverride struct{…}` - `ID PageRuleEditParamsActionsResolveOverrideID` Change the origin address to the value specified in this setting. - `const PageRuleEditParamsActionsResolveOverrideIDResolveOverride PageRuleEditParamsActionsResolveOverrideID = "resolve_override"` - `Value string` The origin address you want to override with. - `type PageRuleEditParamsActionsRespectStrongEtag struct{…}` - `ID PageRuleEditParamsActionsRespectStrongEtagID` Turn on or off byte-for-byte equivalency checks between the Cloudflare cache and the origin server. - `const PageRuleEditParamsActionsRespectStrongEtagIDRespectStrongEtag PageRuleEditParamsActionsRespectStrongEtagID = "respect_strong_etag"` - `Value PageRuleEditParamsActionsRespectStrongEtagValue` The status of Respect Strong ETags - `const PageRuleEditParamsActionsRespectStrongEtagValueOn PageRuleEditParamsActionsRespectStrongEtagValue = "on"` - `const PageRuleEditParamsActionsRespectStrongEtagValueOff PageRuleEditParamsActionsRespectStrongEtagValue = "off"` - `type ResponseBuffering struct{…}` - `ID ResponseBufferingID` Turn on or off whether Cloudflare should wait for an entire file from the origin server before forwarding it to the site visitor. By default, Cloudflare sends packets to the client as they arrive from the origin server. - `const ResponseBufferingIDResponseBuffering ResponseBufferingID = "response_buffering"` - `Value ResponseBufferingValue` The status of Response Buffering - `const ResponseBufferingValueOn ResponseBufferingValue = "on"` - `const ResponseBufferingValueOff ResponseBufferingValue = "off"` - `type RocketLoader struct{…}` - `ID RocketLoaderID` Turn on or off Rocket Loader in the Cloudflare Speed app. - `const RocketLoaderIDRocketLoader RocketLoaderID = "rocket_loader"` - `Value RocketLoaderValue` The status of Rocket Loader - `const RocketLoaderValueOn RocketLoaderValue = "on"` - `const RocketLoaderValueOff RocketLoaderValue = "off"` - `type SecurityLevel struct{…}` - `ID SecurityLevelID` Control options for the **Security Level** feature from the **Security** app. - `const SecurityLevelIDSecurityLevel SecurityLevelID = "security_level"` - `Value SecurityLevelValue` - `const SecurityLevelValueOff SecurityLevelValue = "off"` - `const SecurityLevelValueEssentiallyOff SecurityLevelValue = "essentially_off"` - `const SecurityLevelValueLow SecurityLevelValue = "low"` - `const SecurityLevelValueMedium SecurityLevelValue = "medium"` - `const SecurityLevelValueHigh SecurityLevelValue = "high"` - `const SecurityLevelValueUnderAttack SecurityLevelValue = "under_attack"` - `type SortQueryStringForCache struct{…}` - `ID SortQueryStringForCacheID` Turn on or off the reordering of query strings. When query strings have the same structure, caching improves. - `const SortQueryStringForCacheIDSortQueryStringForCache SortQueryStringForCacheID = "sort_query_string_for_cache"` - `Value SortQueryStringForCacheValue` The status of Query String Sort - `const SortQueryStringForCacheValueOn SortQueryStringForCacheValue = "on"` - `const SortQueryStringForCacheValueOff SortQueryStringForCacheValue = "off"` - `type SSL struct{…}` - `ID SSLID` Control options for the SSL feature of the Edge Certificates tab in the Cloudflare SSL/TLS app. - `const SSLIDSSL SSLID = "ssl"` - `Value SSLValue` The encryption mode that Cloudflare uses to connect to your origin server. - `const SSLValueOff SSLValue = "off"` - `const SSLValueFlexible SSLValue = "flexible"` - `const SSLValueFull SSLValue = "full"` - `const SSLValueStrict SSLValue = "strict"` - `const SSLValueOriginPull SSLValue = "origin_pull"` - `type TrueClientIPHeader struct{…}` - `ID TrueClientIPHeaderID` Turn on or off the True-Client-IP Header feature of the Cloudflare Network app. - `const TrueClientIPHeaderIDTrueClientIPHeader TrueClientIPHeaderID = "true_client_ip_header"` - `Value TrueClientIPHeaderValue` The status of True Client IP Header. - `const TrueClientIPHeaderValueOn TrueClientIPHeaderValue = "on"` - `const TrueClientIPHeaderValueOff TrueClientIPHeaderValue = "off"` - `type WAF struct{…}` - `ID WAFID` Turn on or off [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). You cannot enable or disable individual WAF managed rules via Page Rules. - `const WAFIDWAF WAFID = "waf"` - `Value WAFValue` The status of WAF managed rules (previous version). - `const WAFValueOn WAFValue = "on"` - `const WAFValueOff WAFValue = "off"` - `Priority param.Field[int64]` Body param: The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: `/images/*`) but want a more specific Page Rule to take precedence (rule B: `/images/special/*`), specify a higher priority for rule B so it overrides rule A. - `Status param.Field[PageRuleEditParamsStatus]` Body param: The status of the Page Rule. - `const PageRuleEditParamsStatusActive PageRuleEditParamsStatus = "active"` - `const PageRuleEditParamsStatusDisabled PageRuleEditParamsStatus = "disabled"` - `Targets param.Field[[]Target]` Body param: The rule targets to evaluate on each request. - `Constraint TargetConstraint` String constraint. - `Operator TargetConstraintOperator` The matches operator can use asterisks and pipes as wildcard and 'or' operators. - `const TargetConstraintOperatorMatches TargetConstraintOperator = "matches"` - `const TargetConstraintOperatorContains TargetConstraintOperator = "contains"` - `const TargetConstraintOperatorEquals TargetConstraintOperator = "equals"` - `const TargetConstraintOperatorNotEqual TargetConstraintOperator = "not_equal"` - `const TargetConstraintOperatorNotContain TargetConstraintOperator = "not_contain"` - `Value string` The URL pattern to match against the current request. The pattern may contain up to four asterisks ('*') as placeholders. - `Target TargetTarget` A target based on the URL of the request. - `const TargetTargetURL TargetTarget = "url"` ### Returns - `type PageRule struct{…}` - `ID string` Identifier. - `Actions []PageRuleAction` The set of actions to perform if the targets of this rule match the request. Actions can redirect to another URL or override settings, but not both. - `type AlwaysUseHTTPS struct{…}` - `ID AlwaysUseHTTPSID` If enabled, any `http://`` URL is converted to`https://` through a 301 redirect. - `const AlwaysUseHTTPSIDAlwaysUseHTTPS AlwaysUseHTTPSID = "always_use_https"` - `type AutomaticHTTPSRewrites struct{…}` - `ID AutomaticHTTPSRewritesID` Turn on or off Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesIDAutomaticHTTPSRewrites AutomaticHTTPSRewritesID = "automatic_https_rewrites"` - `Value AutomaticHTTPSRewritesValue` The status of Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesValueOn AutomaticHTTPSRewritesValue = "on"` - `const AutomaticHTTPSRewritesValueOff AutomaticHTTPSRewritesValue = "off"` - `type BrowserCacheTTL struct{…}` - `ID BrowserCacheTTLID` Control how long resources cached by client browsers remain valid. - `const BrowserCacheTTLIDBrowserCacheTTL BrowserCacheTTLID = "browser_cache_ttl"` - `Value int64` The number of seconds to cache resources for. Setting this to 0 enables "Respect Existing Headers". - `type BrowserCheck struct{…}` - `ID BrowserCheckID` Inspect the visitor's browser for headers commonly associated with spammers and certain bots. - `const BrowserCheckIDBrowserCheck BrowserCheckID = "browser_check"` - `Value BrowserCheckValue` The status of Browser Integrity Check. - `const BrowserCheckValueOn BrowserCheckValue = "on"` - `const BrowserCheckValueOff BrowserCheckValue = "off"` - `type PageRuleActionsBypassCacheOnCookie struct{…}` - `ID PageRuleActionsBypassCacheOnCookieID` Bypass cache and fetch resources from the origin server if a regular expression matches against a cookie name present in the request. - `const PageRuleActionsBypassCacheOnCookieIDBypassCacheOnCookie PageRuleActionsBypassCacheOnCookieID = "bypass_cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. Refer to [Bypass Cache on Cookie setting](https://developers.cloudflare.com/rules/page-rules/reference/additional-reference/#bypass-cache-on-cookie-setting) to learn about limited regular expression support. - `type PageRuleActionsCacheByDeviceType struct{…}` - `ID PageRuleActionsCacheByDeviceTypeID` Separate cached content based on the visitor's device type. - `const PageRuleActionsCacheByDeviceTypeIDCacheByDeviceType PageRuleActionsCacheByDeviceTypeID = "cache_by_device_type"` - `Value PageRuleActionsCacheByDeviceTypeValue` The status of Cache By Device Type. - `const PageRuleActionsCacheByDeviceTypeValueOn PageRuleActionsCacheByDeviceTypeValue = "on"` - `const PageRuleActionsCacheByDeviceTypeValueOff PageRuleActionsCacheByDeviceTypeValue = "off"` - `type PageRuleActionsCacheDeceptionArmor struct{…}` - `ID PageRuleActionsCacheDeceptionArmorID` Protect from web cache deception attacks while still allowing static assets to be cached. This setting verifies that the URL's extension matches the returned `Content-Type`. - `const PageRuleActionsCacheDeceptionArmorIDCacheDeceptionArmor PageRuleActionsCacheDeceptionArmorID = "cache_deception_armor"` - `Value PageRuleActionsCacheDeceptionArmorValue` The status of Cache Deception Armor. - `const PageRuleActionsCacheDeceptionArmorValueOn PageRuleActionsCacheDeceptionArmorValue = "on"` - `const PageRuleActionsCacheDeceptionArmorValueOff PageRuleActionsCacheDeceptionArmorValue = "off"` - `type PageRuleActionsCacheKeyFields struct{…}` - `ID PageRuleActionsCacheKeyFieldsID` Control specifically what variables to include when deciding which resources to cache. This allows customers to determine what to cache based on something other than just the URL. - `const PageRuleActionsCacheKeyFieldsIDCacheKeyFields PageRuleActionsCacheKeyFieldsID = "cache_key_fields"` - `Value PageRuleActionsCacheKeyFieldsValue` - `Cookie PageRuleActionsCacheKeyFieldsValueCookie` Controls which cookies appear in the Cache Key. - `CheckPresence []string` A list of cookies to check for the presence of, without including their actual values. - `Include []string` A list of cookies to include. - `Header PageRuleActionsCacheKeyFieldsValueHeader` Controls which headers go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `CheckPresence []string` A list of headers to check for the presence of, without including their actual values. - `Exclude []string` A list of headers to ignore. - `Include []string` A list of headers to include. - `Host PageRuleActionsCacheKeyFieldsValueHost` Determines which host header to include in the Cache Key. - `Resolved bool` Whether to include the Host header in the HTTP request sent to the origin. - `QueryString PageRuleActionsCacheKeyFieldsValueQueryString` Controls which URL query string parameters go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `Exclude PageRuleActionsCacheKeyFieldsValueQueryStringExcludeUnion` Ignore all query string parameters. - `type PageRuleActionsCacheKeyFieldsValueQueryStringExcludeString string` Ignore all query string parameters. - `const PageRuleActionsCacheKeyFieldsValueQueryStringExcludeStringStar PageRuleActionsCacheKeyFieldsValueQueryStringExcludeString = "*"` - `type PageRuleActionsCacheKeyFieldsValueQueryStringExcludeArray []string` A list of query string parameters to ignore. - `Include PageRuleActionsCacheKeyFieldsValueQueryStringIncludeUnion` Include all query string parameters. - `type PageRuleActionsCacheKeyFieldsValueQueryStringIncludeString string` Include all query string parameters. - `const PageRuleActionsCacheKeyFieldsValueQueryStringIncludeStringStar PageRuleActionsCacheKeyFieldsValueQueryStringIncludeString = "*"` - `type PageRuleActionsCacheKeyFieldsValueQueryStringIncludeArray []string` A list of query string parameters to include. - `User PageRuleActionsCacheKeyFieldsValueUser` Feature fields to add features about the end-user (client) into the Cache Key. - `DeviceType bool` Classifies a request as `mobile`, `desktop`, or `tablet` based on the User Agent. - `Geo bool` Includes the client's country, derived from the IP address. - `Lang bool` Includes the first language code contained in the `Accept-Language` header sent by the client. - `type CacheLevel struct{…}` - `ID CacheLevelID` Apply custom caching based on the option selected. - `const CacheLevelIDCacheLevel CacheLevelID = "cache_level"` - `Value CacheLevelValue` * `bypass`: Cloudflare does not cache. * `basic`: Delivers resources from cache when there is no query string. * `simplified`: Delivers the same resource to everyone independent of the query string. * `aggressive`: Caches all static content that has a query string. * `cache_everything`: Treats all content as static and caches all file types beyond the [Cloudflare default cached content](https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#default-cached-file-extensions). - `const CacheLevelValueBypass CacheLevelValue = "bypass"` - `const CacheLevelValueBasic CacheLevelValue = "basic"` - `const CacheLevelValueSimplified CacheLevelValue = "simplified"` - `const CacheLevelValueAggressive CacheLevelValue = "aggressive"` - `const CacheLevelValueCacheEverything CacheLevelValue = "cache_everything"` - `type PageRuleActionsCacheOnCookie struct{…}` - `ID PageRuleActionsCacheOnCookieID` Apply the Cache Everything option (Cache Level setting) based on a regular expression match against a cookie name. - `const PageRuleActionsCacheOnCookieIDCacheOnCookie PageRuleActionsCacheOnCookieID = "cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. - `type PageRuleActionsCacheTTLByStatus struct{…}` - `ID PageRuleActionsCacheTTLByStatusID` Enterprise customers can set cache time-to-live (TTL) based on the response status from the origin web server. Cache TTL refers to the duration of a resource in the Cloudflare network before being marked as stale or discarded from cache. Status codes are returned by a resource's origin. Setting cache TTL based on response status overrides the default cache behavior (standard caching) for static files and overrides cache instructions sent by the origin web server. To cache non-static assets, set a Cache Level of Cache Everything using a Page Rule. Setting no-store Cache-Control or a low TTL (using `max-age`/`s-maxage`) increases requests to origin web servers and decreases performance. - `const PageRuleActionsCacheTTLByStatusIDCacheTTLByStatus PageRuleActionsCacheTTLByStatusID = "cache_ttl_by_status"` - `Value map[string, PageRuleActionsCacheTTLByStatusValueUnion]` A JSON object containing status codes and their corresponding TTLs. Each key-value pair in the cache TTL by status cache rule has the following syntax - `status_code`: An integer value such as 200 or 500. status_code matches the exact status code from the origin web server. Valid status codes are between 100-999. - `status_code_range`: Integer values for from and to. status_code_range matches any status code from the origin web server within the specified range. - `value`: An integer value that defines the duration an asset is valid in seconds or one of the following strings: no-store (equivalent to -1), no-cache (equivalent to 0). - `type PageRuleActionsCacheTTLByStatusValueString string` `no-store` (equivalent to -1), `no-cache` (equivalent to 0) - `const PageRuleActionsCacheTTLByStatusValueStringNoCache PageRuleActionsCacheTTLByStatusValueString = "no-cache"` - `const PageRuleActionsCacheTTLByStatusValueStringNoStore PageRuleActionsCacheTTLByStatusValueString = "no-store"` - `UnionInt` - `type PageRuleActionsDisableApps struct{…}` - `ID PageRuleActionsDisableAppsID` Turn off all active [Cloudflare Apps](https://developers.cloudflare.com/support/more-dashboard-apps/cloudflare-apps/) (deprecated). - `const PageRuleActionsDisableAppsIDDisableApps PageRuleActionsDisableAppsID = "disable_apps"` - `type PageRuleActionsDisablePerformance struct{…}` - `ID PageRuleActionsDisablePerformanceID` Turn off [Rocket Loader](https://developers.cloudflare.com/speed/optimization/content/rocket-loader/), and [Polish](https://developers.cloudflare.com/images/polish/). - `const PageRuleActionsDisablePerformanceIDDisablePerformance PageRuleActionsDisablePerformanceID = "disable_performance"` - `type PageRuleActionsDisableSecurity struct{…}` - `ID PageRuleActionsDisableSecurityID` Turn off [Email Obfuscation](https://developers.cloudflare.com/waf/tools/scrape-shield/email-address-obfuscation/), [Rate Limiting (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/), [Scrape Shield](https://developers.cloudflare.com/waf/tools/scrape-shield/), [URL (Zone) Lockdown](https://developers.cloudflare.com/waf/tools/zone-lockdown/), and [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). - `const PageRuleActionsDisableSecurityIDDisableSecurity PageRuleActionsDisableSecurityID = "disable_security"` - `type PageRuleActionsDisableZaraz struct{…}` - `ID PageRuleActionsDisableZarazID` Turn off [Zaraz](https://developers.cloudflare.com/zaraz/). - `const PageRuleActionsDisableZarazIDDisableZaraz PageRuleActionsDisableZarazID = "disable_zaraz"` - `type PageRuleActionsEdgeCacheTTL struct{…}` - `ID PageRuleActionsEdgeCacheTTLID` Specify how long to cache a resource in the Cloudflare global network. *Edge Cache TTL* is not visible in response headers. - `const PageRuleActionsEdgeCacheTTLIDEdgeCacheTTL PageRuleActionsEdgeCacheTTLID = "edge_cache_ttl"` - `Value int64` - `type EmailObfuscation struct{…}` - `ID EmailObfuscationID` Turn on or off **Email Obfuscation**. - `const EmailObfuscationIDEmailObfuscation EmailObfuscationID = "email_obfuscation"` - `Value EmailObfuscationValue` The status of Email Obfuscation. - `const EmailObfuscationValueOn EmailObfuscationValue = "on"` - `const EmailObfuscationValueOff EmailObfuscationValue = "off"` - `type PageRuleActionsExplicitCacheControl struct{…}` - `ID PageRuleActionsExplicitCacheControlID` Origin Cache Control is enabled by default for Free, Pro, and Business domains and disabled by default for Enterprise domains. - `const PageRuleActionsExplicitCacheControlIDExplicitCacheControl PageRuleActionsExplicitCacheControlID = "explicit_cache_control"` - `Value PageRuleActionsExplicitCacheControlValue` The status of Origin Cache Control. - `const PageRuleActionsExplicitCacheControlValueOn PageRuleActionsExplicitCacheControlValue = "on"` - `const PageRuleActionsExplicitCacheControlValueOff PageRuleActionsExplicitCacheControlValue = "off"` - `type PageRuleActionsForwardingURL struct{…}` - `ID PageRuleActionsForwardingURLID` Redirects one URL to another using an `HTTP 301/302` redirect. Refer to [Wildcard matching and referencing](https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/). - `const PageRuleActionsForwardingURLIDForwardingURL PageRuleActionsForwardingURLID = "forwarding_url"` - `Value PageRuleActionsForwardingURLValue` - `StatusCode PageRuleActionsForwardingURLValueStatusCode` The status code to use for the URL redirect. 301 is a permanent redirect. 302 is a temporary redirect. - `const PageRuleActionsForwardingURLValueStatusCode301 PageRuleActionsForwardingURLValueStatusCode = 301` - `const PageRuleActionsForwardingURLValueStatusCode302 PageRuleActionsForwardingURLValueStatusCode = 302` - `URL string` The URL to redirect the request to. Notes: ${num} refers to the position of '*' in the constraint value. - `type PageRuleActionsHostHeaderOverride struct{…}` - `ID PageRuleActionsHostHeaderOverrideID` Apply a specific host header. - `const PageRuleActionsHostHeaderOverrideIDHostHeaderOverride PageRuleActionsHostHeaderOverrideID = "host_header_override"` - `Value string` The hostname to use in the `Host` header - `type IPGeolocation struct{…}` - `ID IPGeolocationID` Cloudflare adds a CF-IPCountry HTTP header containing the country code that corresponds to the visitor. - `const IPGeolocationIDIPGeolocation IPGeolocationID = "ip_geolocation"` - `Value IPGeolocationValue` The status of adding the IP Geolocation Header. - `const IPGeolocationValueOn IPGeolocationValue = "on"` - `const IPGeolocationValueOff IPGeolocationValue = "off"` - `type Mirage struct{…}` - `ID MirageID` Cloudflare Mirage reduces bandwidth used by images in mobile browsers. It can accelerate loading of image-heavy websites on very slow mobile connections and HTTP/1. - `const MirageIDMirage MirageID = "mirage"` - `Value MirageValue` The status of Mirage. - `const MirageValueOn MirageValue = "on"` - `const MirageValueOff MirageValue = "off"` - `type OpportunisticEncryption struct{…}` - `ID OpportunisticEncryptionID` Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted TLS channel. It's not a substitute for HTTPS, but provides additional security for otherwise vulnerable requests. - `const OpportunisticEncryptionIDOpportunisticEncryption OpportunisticEncryptionID = "opportunistic_encryption"` - `Value OpportunisticEncryptionValue` The status of Opportunistic Encryption. - `const OpportunisticEncryptionValueOn OpportunisticEncryptionValue = "on"` - `const OpportunisticEncryptionValueOff OpportunisticEncryptionValue = "off"` - `type OriginErrorPagePassThru struct{…}` - `ID OriginErrorPagePassThruID` Turn on or off Cloudflare error pages generated from issues sent from the origin server. If enabled, this setting triggers error pages issued by the origin. - `const OriginErrorPagePassThruIDOriginErrorPagePassThru OriginErrorPagePassThruID = "origin_error_page_pass_thru"` - `Value OriginErrorPagePassThruValue` The status of Origin Error Page Passthru. - `const OriginErrorPagePassThruValueOn OriginErrorPagePassThruValue = "on"` - `const OriginErrorPagePassThruValueOff OriginErrorPagePassThruValue = "off"` - `type Polish struct{…}` - `ID PolishID` Apply options from the Polish feature of the Cloudflare Speed app. - `const PolishIDPolish PolishID = "polish"` - `Value PolishValue` The level of Polish you want applied to your origin. - `const PolishValueOff PolishValue = "off"` - `const PolishValueLossless PolishValue = "lossless"` - `const PolishValueLossy PolishValue = "lossy"` - `type PageRuleActionsResolveOverride struct{…}` - `ID PageRuleActionsResolveOverrideID` Change the origin address to the value specified in this setting. - `const PageRuleActionsResolveOverrideIDResolveOverride PageRuleActionsResolveOverrideID = "resolve_override"` - `Value string` The origin address you want to override with. - `type PageRuleActionsRespectStrongEtag struct{…}` - `ID PageRuleActionsRespectStrongEtagID` Turn on or off byte-for-byte equivalency checks between the Cloudflare cache and the origin server. - `const PageRuleActionsRespectStrongEtagIDRespectStrongEtag PageRuleActionsRespectStrongEtagID = "respect_strong_etag"` - `Value PageRuleActionsRespectStrongEtagValue` The status of Respect Strong ETags - `const PageRuleActionsRespectStrongEtagValueOn PageRuleActionsRespectStrongEtagValue = "on"` - `const PageRuleActionsRespectStrongEtagValueOff PageRuleActionsRespectStrongEtagValue = "off"` - `type ResponseBuffering struct{…}` - `ID ResponseBufferingID` Turn on or off whether Cloudflare should wait for an entire file from the origin server before forwarding it to the site visitor. By default, Cloudflare sends packets to the client as they arrive from the origin server. - `const ResponseBufferingIDResponseBuffering ResponseBufferingID = "response_buffering"` - `Value ResponseBufferingValue` The status of Response Buffering - `const ResponseBufferingValueOn ResponseBufferingValue = "on"` - `const ResponseBufferingValueOff ResponseBufferingValue = "off"` - `type RocketLoader struct{…}` - `ID RocketLoaderID` Turn on or off Rocket Loader in the Cloudflare Speed app. - `const RocketLoaderIDRocketLoader RocketLoaderID = "rocket_loader"` - `Value RocketLoaderValue` The status of Rocket Loader - `const RocketLoaderValueOn RocketLoaderValue = "on"` - `const RocketLoaderValueOff RocketLoaderValue = "off"` - `type SecurityLevel struct{…}` - `ID SecurityLevelID` Control options for the **Security Level** feature from the **Security** app. - `const SecurityLevelIDSecurityLevel SecurityLevelID = "security_level"` - `Value SecurityLevelValue` - `const SecurityLevelValueOff SecurityLevelValue = "off"` - `const SecurityLevelValueEssentiallyOff SecurityLevelValue = "essentially_off"` - `const SecurityLevelValueLow SecurityLevelValue = "low"` - `const SecurityLevelValueMedium SecurityLevelValue = "medium"` - `const SecurityLevelValueHigh SecurityLevelValue = "high"` - `const SecurityLevelValueUnderAttack SecurityLevelValue = "under_attack"` - `type SortQueryStringForCache struct{…}` - `ID SortQueryStringForCacheID` Turn on or off the reordering of query strings. When query strings have the same structure, caching improves. - `const SortQueryStringForCacheIDSortQueryStringForCache SortQueryStringForCacheID = "sort_query_string_for_cache"` - `Value SortQueryStringForCacheValue` The status of Query String Sort - `const SortQueryStringForCacheValueOn SortQueryStringForCacheValue = "on"` - `const SortQueryStringForCacheValueOff SortQueryStringForCacheValue = "off"` - `type SSL struct{…}` - `ID SSLID` Control options for the SSL feature of the Edge Certificates tab in the Cloudflare SSL/TLS app. - `const SSLIDSSL SSLID = "ssl"` - `Value SSLValue` The encryption mode that Cloudflare uses to connect to your origin server. - `const SSLValueOff SSLValue = "off"` - `const SSLValueFlexible SSLValue = "flexible"` - `const SSLValueFull SSLValue = "full"` - `const SSLValueStrict SSLValue = "strict"` - `const SSLValueOriginPull SSLValue = "origin_pull"` - `type TrueClientIPHeader struct{…}` - `ID TrueClientIPHeaderID` Turn on or off the True-Client-IP Header feature of the Cloudflare Network app. - `const TrueClientIPHeaderIDTrueClientIPHeader TrueClientIPHeaderID = "true_client_ip_header"` - `Value TrueClientIPHeaderValue` The status of True Client IP Header. - `const TrueClientIPHeaderValueOn TrueClientIPHeaderValue = "on"` - `const TrueClientIPHeaderValueOff TrueClientIPHeaderValue = "off"` - `type WAF struct{…}` - `ID WAFID` Turn on or off [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). You cannot enable or disable individual WAF managed rules via Page Rules. - `const WAFIDWAF WAFID = "waf"` - `Value WAFValue` The status of WAF managed rules (previous version). - `const WAFValueOn WAFValue = "on"` - `const WAFValueOff WAFValue = "off"` - `CreatedOn Time` The timestamp of when the Page Rule was created. - `ModifiedOn Time` The timestamp of when the Page Rule was last modified. - `Priority int64` The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: `/images/*`) but want a more specific Page Rule to take precedence (rule B: `/images/special/*`), specify a higher priority for rule B so it overrides rule A. - `Status PageRuleStatus` The status of the Page Rule. - `const PageRuleStatusActive PageRuleStatus = "active"` - `const PageRuleStatusDisabled PageRuleStatus = "disabled"` - `Targets []Target` The rule targets to evaluate on each request. - `Constraint TargetConstraint` String constraint. - `Operator TargetConstraintOperator` The matches operator can use asterisks and pipes as wildcard and 'or' operators. - `const TargetConstraintOperatorMatches TargetConstraintOperator = "matches"` - `const TargetConstraintOperatorContains TargetConstraintOperator = "contains"` - `const TargetConstraintOperatorEquals TargetConstraintOperator = "equals"` - `const TargetConstraintOperatorNotEqual TargetConstraintOperator = "not_equal"` - `const TargetConstraintOperatorNotContain TargetConstraintOperator = "not_contain"` - `Value string` The URL pattern to match against the current request. The pattern may contain up to four asterisks ('*') as placeholders. - `Target TargetTarget` A target based on the URL of the request. - `const TargetTargetURL TargetTarget = "url"` ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/page_rules" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) pageRule, err := client.PageRules.Edit( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", page_rules.PageRuleEditParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", pageRule.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353", "actions": [ { "id": "browser_check", "value": "on" } ], "created_on": "2014-01-01T05:20:00.12345Z", "modified_on": "2014-01-01T05:20:00.12345Z", "priority": 0, "status": "active", "targets": [ { "constraint": { "operator": "matches", "value": "*example.com/images/*" }, "target": "url" } ] } } ``` ## Delete a Page Rule `client.PageRules.Delete(ctx, pageruleID, body) (*PageRuleDeleteResponse, error)` **delete** `/zones/{zone_id}/pagerules/{pagerule_id}` Deletes an existing Page Rule. ### Parameters - `pageruleID string` Identifier. - `body PageRuleDeleteParams` - `ZoneID param.Field[string]` Identifier. ### Returns - `type PageRuleDeleteResponse struct{…}` - `ID string` Identifier. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/option" "github.com/cloudflare/cloudflare-go/page_rules" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) pageRule, err := client.PageRules.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", page_rules.PageRuleDeleteParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", pageRule.ID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "success": true, "result": { "id": "023e105f4ecef8ad9ca31a8372d0c353" } } ``` ## Domain Types ### Page Rule - `type PageRule struct{…}` - `ID string` Identifier. - `Actions []PageRuleAction` The set of actions to perform if the targets of this rule match the request. Actions can redirect to another URL or override settings, but not both. - `type AlwaysUseHTTPS struct{…}` - `ID AlwaysUseHTTPSID` If enabled, any `http://`` URL is converted to`https://` through a 301 redirect. - `const AlwaysUseHTTPSIDAlwaysUseHTTPS AlwaysUseHTTPSID = "always_use_https"` - `type AutomaticHTTPSRewrites struct{…}` - `ID AutomaticHTTPSRewritesID` Turn on or off Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesIDAutomaticHTTPSRewrites AutomaticHTTPSRewritesID = "automatic_https_rewrites"` - `Value AutomaticHTTPSRewritesValue` The status of Automatic HTTPS Rewrites. - `const AutomaticHTTPSRewritesValueOn AutomaticHTTPSRewritesValue = "on"` - `const AutomaticHTTPSRewritesValueOff AutomaticHTTPSRewritesValue = "off"` - `type BrowserCacheTTL struct{…}` - `ID BrowserCacheTTLID` Control how long resources cached by client browsers remain valid. - `const BrowserCacheTTLIDBrowserCacheTTL BrowserCacheTTLID = "browser_cache_ttl"` - `Value int64` The number of seconds to cache resources for. Setting this to 0 enables "Respect Existing Headers". - `type BrowserCheck struct{…}` - `ID BrowserCheckID` Inspect the visitor's browser for headers commonly associated with spammers and certain bots. - `const BrowserCheckIDBrowserCheck BrowserCheckID = "browser_check"` - `Value BrowserCheckValue` The status of Browser Integrity Check. - `const BrowserCheckValueOn BrowserCheckValue = "on"` - `const BrowserCheckValueOff BrowserCheckValue = "off"` - `type PageRuleActionsBypassCacheOnCookie struct{…}` - `ID PageRuleActionsBypassCacheOnCookieID` Bypass cache and fetch resources from the origin server if a regular expression matches against a cookie name present in the request. - `const PageRuleActionsBypassCacheOnCookieIDBypassCacheOnCookie PageRuleActionsBypassCacheOnCookieID = "bypass_cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. Refer to [Bypass Cache on Cookie setting](https://developers.cloudflare.com/rules/page-rules/reference/additional-reference/#bypass-cache-on-cookie-setting) to learn about limited regular expression support. - `type PageRuleActionsCacheByDeviceType struct{…}` - `ID PageRuleActionsCacheByDeviceTypeID` Separate cached content based on the visitor's device type. - `const PageRuleActionsCacheByDeviceTypeIDCacheByDeviceType PageRuleActionsCacheByDeviceTypeID = "cache_by_device_type"` - `Value PageRuleActionsCacheByDeviceTypeValue` The status of Cache By Device Type. - `const PageRuleActionsCacheByDeviceTypeValueOn PageRuleActionsCacheByDeviceTypeValue = "on"` - `const PageRuleActionsCacheByDeviceTypeValueOff PageRuleActionsCacheByDeviceTypeValue = "off"` - `type PageRuleActionsCacheDeceptionArmor struct{…}` - `ID PageRuleActionsCacheDeceptionArmorID` Protect from web cache deception attacks while still allowing static assets to be cached. This setting verifies that the URL's extension matches the returned `Content-Type`. - `const PageRuleActionsCacheDeceptionArmorIDCacheDeceptionArmor PageRuleActionsCacheDeceptionArmorID = "cache_deception_armor"` - `Value PageRuleActionsCacheDeceptionArmorValue` The status of Cache Deception Armor. - `const PageRuleActionsCacheDeceptionArmorValueOn PageRuleActionsCacheDeceptionArmorValue = "on"` - `const PageRuleActionsCacheDeceptionArmorValueOff PageRuleActionsCacheDeceptionArmorValue = "off"` - `type PageRuleActionsCacheKeyFields struct{…}` - `ID PageRuleActionsCacheKeyFieldsID` Control specifically what variables to include when deciding which resources to cache. This allows customers to determine what to cache based on something other than just the URL. - `const PageRuleActionsCacheKeyFieldsIDCacheKeyFields PageRuleActionsCacheKeyFieldsID = "cache_key_fields"` - `Value PageRuleActionsCacheKeyFieldsValue` - `Cookie PageRuleActionsCacheKeyFieldsValueCookie` Controls which cookies appear in the Cache Key. - `CheckPresence []string` A list of cookies to check for the presence of, without including their actual values. - `Include []string` A list of cookies to include. - `Header PageRuleActionsCacheKeyFieldsValueHeader` Controls which headers go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `CheckPresence []string` A list of headers to check for the presence of, without including their actual values. - `Exclude []string` A list of headers to ignore. - `Include []string` A list of headers to include. - `Host PageRuleActionsCacheKeyFieldsValueHost` Determines which host header to include in the Cache Key. - `Resolved bool` Whether to include the Host header in the HTTP request sent to the origin. - `QueryString PageRuleActionsCacheKeyFieldsValueQueryString` Controls which URL query string parameters go into the Cache Key. Exactly one of `include` or `exclude` is expected. - `Exclude PageRuleActionsCacheKeyFieldsValueQueryStringExcludeUnion` Ignore all query string parameters. - `type PageRuleActionsCacheKeyFieldsValueQueryStringExcludeString string` Ignore all query string parameters. - `const PageRuleActionsCacheKeyFieldsValueQueryStringExcludeStringStar PageRuleActionsCacheKeyFieldsValueQueryStringExcludeString = "*"` - `type PageRuleActionsCacheKeyFieldsValueQueryStringExcludeArray []string` A list of query string parameters to ignore. - `Include PageRuleActionsCacheKeyFieldsValueQueryStringIncludeUnion` Include all query string parameters. - `type PageRuleActionsCacheKeyFieldsValueQueryStringIncludeString string` Include all query string parameters. - `const PageRuleActionsCacheKeyFieldsValueQueryStringIncludeStringStar PageRuleActionsCacheKeyFieldsValueQueryStringIncludeString = "*"` - `type PageRuleActionsCacheKeyFieldsValueQueryStringIncludeArray []string` A list of query string parameters to include. - `User PageRuleActionsCacheKeyFieldsValueUser` Feature fields to add features about the end-user (client) into the Cache Key. - `DeviceType bool` Classifies a request as `mobile`, `desktop`, or `tablet` based on the User Agent. - `Geo bool` Includes the client's country, derived from the IP address. - `Lang bool` Includes the first language code contained in the `Accept-Language` header sent by the client. - `type CacheLevel struct{…}` - `ID CacheLevelID` Apply custom caching based on the option selected. - `const CacheLevelIDCacheLevel CacheLevelID = "cache_level"` - `Value CacheLevelValue` * `bypass`: Cloudflare does not cache. * `basic`: Delivers resources from cache when there is no query string. * `simplified`: Delivers the same resource to everyone independent of the query string. * `aggressive`: Caches all static content that has a query string. * `cache_everything`: Treats all content as static and caches all file types beyond the [Cloudflare default cached content](https://developers.cloudflare.com/cache/concepts/default-cache-behavior/#default-cached-file-extensions). - `const CacheLevelValueBypass CacheLevelValue = "bypass"` - `const CacheLevelValueBasic CacheLevelValue = "basic"` - `const CacheLevelValueSimplified CacheLevelValue = "simplified"` - `const CacheLevelValueAggressive CacheLevelValue = "aggressive"` - `const CacheLevelValueCacheEverything CacheLevelValue = "cache_everything"` - `type PageRuleActionsCacheOnCookie struct{…}` - `ID PageRuleActionsCacheOnCookieID` Apply the Cache Everything option (Cache Level setting) based on a regular expression match against a cookie name. - `const PageRuleActionsCacheOnCookieIDCacheOnCookie PageRuleActionsCacheOnCookieID = "cache_on_cookie"` - `Value string` The regular expression to use for matching cookie names in the request. - `type PageRuleActionsCacheTTLByStatus struct{…}` - `ID PageRuleActionsCacheTTLByStatusID` Enterprise customers can set cache time-to-live (TTL) based on the response status from the origin web server. Cache TTL refers to the duration of a resource in the Cloudflare network before being marked as stale or discarded from cache. Status codes are returned by a resource's origin. Setting cache TTL based on response status overrides the default cache behavior (standard caching) for static files and overrides cache instructions sent by the origin web server. To cache non-static assets, set a Cache Level of Cache Everything using a Page Rule. Setting no-store Cache-Control or a low TTL (using `max-age`/`s-maxage`) increases requests to origin web servers and decreases performance. - `const PageRuleActionsCacheTTLByStatusIDCacheTTLByStatus PageRuleActionsCacheTTLByStatusID = "cache_ttl_by_status"` - `Value map[string, PageRuleActionsCacheTTLByStatusValueUnion]` A JSON object containing status codes and their corresponding TTLs. Each key-value pair in the cache TTL by status cache rule has the following syntax - `status_code`: An integer value such as 200 or 500. status_code matches the exact status code from the origin web server. Valid status codes are between 100-999. - `status_code_range`: Integer values for from and to. status_code_range matches any status code from the origin web server within the specified range. - `value`: An integer value that defines the duration an asset is valid in seconds or one of the following strings: no-store (equivalent to -1), no-cache (equivalent to 0). - `type PageRuleActionsCacheTTLByStatusValueString string` `no-store` (equivalent to -1), `no-cache` (equivalent to 0) - `const PageRuleActionsCacheTTLByStatusValueStringNoCache PageRuleActionsCacheTTLByStatusValueString = "no-cache"` - `const PageRuleActionsCacheTTLByStatusValueStringNoStore PageRuleActionsCacheTTLByStatusValueString = "no-store"` - `UnionInt` - `type PageRuleActionsDisableApps struct{…}` - `ID PageRuleActionsDisableAppsID` Turn off all active [Cloudflare Apps](https://developers.cloudflare.com/support/more-dashboard-apps/cloudflare-apps/) (deprecated). - `const PageRuleActionsDisableAppsIDDisableApps PageRuleActionsDisableAppsID = "disable_apps"` - `type PageRuleActionsDisablePerformance struct{…}` - `ID PageRuleActionsDisablePerformanceID` Turn off [Rocket Loader](https://developers.cloudflare.com/speed/optimization/content/rocket-loader/), and [Polish](https://developers.cloudflare.com/images/polish/). - `const PageRuleActionsDisablePerformanceIDDisablePerformance PageRuleActionsDisablePerformanceID = "disable_performance"` - `type PageRuleActionsDisableSecurity struct{…}` - `ID PageRuleActionsDisableSecurityID` Turn off [Email Obfuscation](https://developers.cloudflare.com/waf/tools/scrape-shield/email-address-obfuscation/), [Rate Limiting (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-rate-limiting/), [Scrape Shield](https://developers.cloudflare.com/waf/tools/scrape-shield/), [URL (Zone) Lockdown](https://developers.cloudflare.com/waf/tools/zone-lockdown/), and [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). - `const PageRuleActionsDisableSecurityIDDisableSecurity PageRuleActionsDisableSecurityID = "disable_security"` - `type PageRuleActionsDisableZaraz struct{…}` - `ID PageRuleActionsDisableZarazID` Turn off [Zaraz](https://developers.cloudflare.com/zaraz/). - `const PageRuleActionsDisableZarazIDDisableZaraz PageRuleActionsDisableZarazID = "disable_zaraz"` - `type PageRuleActionsEdgeCacheTTL struct{…}` - `ID PageRuleActionsEdgeCacheTTLID` Specify how long to cache a resource in the Cloudflare global network. *Edge Cache TTL* is not visible in response headers. - `const PageRuleActionsEdgeCacheTTLIDEdgeCacheTTL PageRuleActionsEdgeCacheTTLID = "edge_cache_ttl"` - `Value int64` - `type EmailObfuscation struct{…}` - `ID EmailObfuscationID` Turn on or off **Email Obfuscation**. - `const EmailObfuscationIDEmailObfuscation EmailObfuscationID = "email_obfuscation"` - `Value EmailObfuscationValue` The status of Email Obfuscation. - `const EmailObfuscationValueOn EmailObfuscationValue = "on"` - `const EmailObfuscationValueOff EmailObfuscationValue = "off"` - `type PageRuleActionsExplicitCacheControl struct{…}` - `ID PageRuleActionsExplicitCacheControlID` Origin Cache Control is enabled by default for Free, Pro, and Business domains and disabled by default for Enterprise domains. - `const PageRuleActionsExplicitCacheControlIDExplicitCacheControl PageRuleActionsExplicitCacheControlID = "explicit_cache_control"` - `Value PageRuleActionsExplicitCacheControlValue` The status of Origin Cache Control. - `const PageRuleActionsExplicitCacheControlValueOn PageRuleActionsExplicitCacheControlValue = "on"` - `const PageRuleActionsExplicitCacheControlValueOff PageRuleActionsExplicitCacheControlValue = "off"` - `type PageRuleActionsForwardingURL struct{…}` - `ID PageRuleActionsForwardingURLID` Redirects one URL to another using an `HTTP 301/302` redirect. Refer to [Wildcard matching and referencing](https://developers.cloudflare.com/rules/page-rules/reference/wildcard-matching/). - `const PageRuleActionsForwardingURLIDForwardingURL PageRuleActionsForwardingURLID = "forwarding_url"` - `Value PageRuleActionsForwardingURLValue` - `StatusCode PageRuleActionsForwardingURLValueStatusCode` The status code to use for the URL redirect. 301 is a permanent redirect. 302 is a temporary redirect. - `const PageRuleActionsForwardingURLValueStatusCode301 PageRuleActionsForwardingURLValueStatusCode = 301` - `const PageRuleActionsForwardingURLValueStatusCode302 PageRuleActionsForwardingURLValueStatusCode = 302` - `URL string` The URL to redirect the request to. Notes: ${num} refers to the position of '*' in the constraint value. - `type PageRuleActionsHostHeaderOverride struct{…}` - `ID PageRuleActionsHostHeaderOverrideID` Apply a specific host header. - `const PageRuleActionsHostHeaderOverrideIDHostHeaderOverride PageRuleActionsHostHeaderOverrideID = "host_header_override"` - `Value string` The hostname to use in the `Host` header - `type IPGeolocation struct{…}` - `ID IPGeolocationID` Cloudflare adds a CF-IPCountry HTTP header containing the country code that corresponds to the visitor. - `const IPGeolocationIDIPGeolocation IPGeolocationID = "ip_geolocation"` - `Value IPGeolocationValue` The status of adding the IP Geolocation Header. - `const IPGeolocationValueOn IPGeolocationValue = "on"` - `const IPGeolocationValueOff IPGeolocationValue = "off"` - `type Mirage struct{…}` - `ID MirageID` Cloudflare Mirage reduces bandwidth used by images in mobile browsers. It can accelerate loading of image-heavy websites on very slow mobile connections and HTTP/1. - `const MirageIDMirage MirageID = "mirage"` - `Value MirageValue` The status of Mirage. - `const MirageValueOn MirageValue = "on"` - `const MirageValueOff MirageValue = "off"` - `type OpportunisticEncryption struct{…}` - `ID OpportunisticEncryptionID` Opportunistic Encryption allows browsers to access HTTP URIs over an encrypted TLS channel. It's not a substitute for HTTPS, but provides additional security for otherwise vulnerable requests. - `const OpportunisticEncryptionIDOpportunisticEncryption OpportunisticEncryptionID = "opportunistic_encryption"` - `Value OpportunisticEncryptionValue` The status of Opportunistic Encryption. - `const OpportunisticEncryptionValueOn OpportunisticEncryptionValue = "on"` - `const OpportunisticEncryptionValueOff OpportunisticEncryptionValue = "off"` - `type OriginErrorPagePassThru struct{…}` - `ID OriginErrorPagePassThruID` Turn on or off Cloudflare error pages generated from issues sent from the origin server. If enabled, this setting triggers error pages issued by the origin. - `const OriginErrorPagePassThruIDOriginErrorPagePassThru OriginErrorPagePassThruID = "origin_error_page_pass_thru"` - `Value OriginErrorPagePassThruValue` The status of Origin Error Page Passthru. - `const OriginErrorPagePassThruValueOn OriginErrorPagePassThruValue = "on"` - `const OriginErrorPagePassThruValueOff OriginErrorPagePassThruValue = "off"` - `type Polish struct{…}` - `ID PolishID` Apply options from the Polish feature of the Cloudflare Speed app. - `const PolishIDPolish PolishID = "polish"` - `Value PolishValue` The level of Polish you want applied to your origin. - `const PolishValueOff PolishValue = "off"` - `const PolishValueLossless PolishValue = "lossless"` - `const PolishValueLossy PolishValue = "lossy"` - `type PageRuleActionsResolveOverride struct{…}` - `ID PageRuleActionsResolveOverrideID` Change the origin address to the value specified in this setting. - `const PageRuleActionsResolveOverrideIDResolveOverride PageRuleActionsResolveOverrideID = "resolve_override"` - `Value string` The origin address you want to override with. - `type PageRuleActionsRespectStrongEtag struct{…}` - `ID PageRuleActionsRespectStrongEtagID` Turn on or off byte-for-byte equivalency checks between the Cloudflare cache and the origin server. - `const PageRuleActionsRespectStrongEtagIDRespectStrongEtag PageRuleActionsRespectStrongEtagID = "respect_strong_etag"` - `Value PageRuleActionsRespectStrongEtagValue` The status of Respect Strong ETags - `const PageRuleActionsRespectStrongEtagValueOn PageRuleActionsRespectStrongEtagValue = "on"` - `const PageRuleActionsRespectStrongEtagValueOff PageRuleActionsRespectStrongEtagValue = "off"` - `type ResponseBuffering struct{…}` - `ID ResponseBufferingID` Turn on or off whether Cloudflare should wait for an entire file from the origin server before forwarding it to the site visitor. By default, Cloudflare sends packets to the client as they arrive from the origin server. - `const ResponseBufferingIDResponseBuffering ResponseBufferingID = "response_buffering"` - `Value ResponseBufferingValue` The status of Response Buffering - `const ResponseBufferingValueOn ResponseBufferingValue = "on"` - `const ResponseBufferingValueOff ResponseBufferingValue = "off"` - `type RocketLoader struct{…}` - `ID RocketLoaderID` Turn on or off Rocket Loader in the Cloudflare Speed app. - `const RocketLoaderIDRocketLoader RocketLoaderID = "rocket_loader"` - `Value RocketLoaderValue` The status of Rocket Loader - `const RocketLoaderValueOn RocketLoaderValue = "on"` - `const RocketLoaderValueOff RocketLoaderValue = "off"` - `type SecurityLevel struct{…}` - `ID SecurityLevelID` Control options for the **Security Level** feature from the **Security** app. - `const SecurityLevelIDSecurityLevel SecurityLevelID = "security_level"` - `Value SecurityLevelValue` - `const SecurityLevelValueOff SecurityLevelValue = "off"` - `const SecurityLevelValueEssentiallyOff SecurityLevelValue = "essentially_off"` - `const SecurityLevelValueLow SecurityLevelValue = "low"` - `const SecurityLevelValueMedium SecurityLevelValue = "medium"` - `const SecurityLevelValueHigh SecurityLevelValue = "high"` - `const SecurityLevelValueUnderAttack SecurityLevelValue = "under_attack"` - `type SortQueryStringForCache struct{…}` - `ID SortQueryStringForCacheID` Turn on or off the reordering of query strings. When query strings have the same structure, caching improves. - `const SortQueryStringForCacheIDSortQueryStringForCache SortQueryStringForCacheID = "sort_query_string_for_cache"` - `Value SortQueryStringForCacheValue` The status of Query String Sort - `const SortQueryStringForCacheValueOn SortQueryStringForCacheValue = "on"` - `const SortQueryStringForCacheValueOff SortQueryStringForCacheValue = "off"` - `type SSL struct{…}` - `ID SSLID` Control options for the SSL feature of the Edge Certificates tab in the Cloudflare SSL/TLS app. - `const SSLIDSSL SSLID = "ssl"` - `Value SSLValue` The encryption mode that Cloudflare uses to connect to your origin server. - `const SSLValueOff SSLValue = "off"` - `const SSLValueFlexible SSLValue = "flexible"` - `const SSLValueFull SSLValue = "full"` - `const SSLValueStrict SSLValue = "strict"` - `const SSLValueOriginPull SSLValue = "origin_pull"` - `type TrueClientIPHeader struct{…}` - `ID TrueClientIPHeaderID` Turn on or off the True-Client-IP Header feature of the Cloudflare Network app. - `const TrueClientIPHeaderIDTrueClientIPHeader TrueClientIPHeaderID = "true_client_ip_header"` - `Value TrueClientIPHeaderValue` The status of True Client IP Header. - `const TrueClientIPHeaderValueOn TrueClientIPHeaderValue = "on"` - `const TrueClientIPHeaderValueOff TrueClientIPHeaderValue = "off"` - `type WAF struct{…}` - `ID WAFID` Turn on or off [WAF managed rules (previous version, deprecated)](https://developers.cloudflare.com/waf/reference/legacy/old-waf-managed-rules/). You cannot enable or disable individual WAF managed rules via Page Rules. - `const WAFIDWAF WAFID = "waf"` - `Value WAFValue` The status of WAF managed rules (previous version). - `const WAFValueOn WAFValue = "on"` - `const WAFValueOff WAFValue = "off"` - `CreatedOn Time` The timestamp of when the Page Rule was created. - `ModifiedOn Time` The timestamp of when the Page Rule was last modified. - `Priority int64` The priority of the rule, used to define which Page Rule is processed over another. A higher number indicates a higher priority. For example, if you have a catch-all Page Rule (rule A: `/images/*`) but want a more specific Page Rule to take precedence (rule B: `/images/special/*`), specify a higher priority for rule B so it overrides rule A. - `Status PageRuleStatus` The status of the Page Rule. - `const PageRuleStatusActive PageRuleStatus = "active"` - `const PageRuleStatusDisabled PageRuleStatus = "disabled"` - `Targets []Target` The rule targets to evaluate on each request. - `Constraint TargetConstraint` String constraint. - `Operator TargetConstraintOperator` The matches operator can use asterisks and pipes as wildcard and 'or' operators. - `const TargetConstraintOperatorMatches TargetConstraintOperator = "matches"` - `const TargetConstraintOperatorContains TargetConstraintOperator = "contains"` - `const TargetConstraintOperatorEquals TargetConstraintOperator = "equals"` - `const TargetConstraintOperatorNotEqual TargetConstraintOperator = "not_equal"` - `const TargetConstraintOperatorNotContain TargetConstraintOperator = "not_contain"` - `Value string` The URL pattern to match against the current request. The pattern may contain up to four asterisks ('*') as placeholders. - `Target TargetTarget` A target based on the URL of the request. - `const TargetTargetURL TargetTarget = "url"` ### Target - `type Target struct{…}` URL target. - `Constraint TargetConstraint` String constraint. - `Operator TargetConstraintOperator` The matches operator can use asterisks and pipes as wildcard and 'or' operators. - `const TargetConstraintOperatorMatches TargetConstraintOperator = "matches"` - `const TargetConstraintOperatorContains TargetConstraintOperator = "contains"` - `const TargetConstraintOperatorEquals TargetConstraintOperator = "equals"` - `const TargetConstraintOperatorNotEqual TargetConstraintOperator = "not_equal"` - `const TargetConstraintOperatorNotContain TargetConstraintOperator = "not_contain"` - `Value string` The URL pattern to match against the current request. The pattern may contain up to four asterisks ('*') as placeholders. - `Target TargetTarget` A target based on the URL of the request. - `const TargetTargetURL TargetTarget = "url"`