You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/cache/how-to/cache-keys.mdx
+10-6Lines changed: 10 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,17 +47,21 @@ There are a couple of common reasons to change the Cache Key Template. You might
47
47
48
48
### Impact of SSL settings on Cache behavior
49
49
50
-
The`$scheme`refers to the protocol (HTTP or HTTPS) sent to your origin web server, not the protocol received from the visitor. Therefore, setting the Cloudflare [SSL option](/ssl/origin-configuration/ssl-modes/) influences caching decisions. For example, when using [Flexible SSL](/ssl/origin-configuration/ssl-modes/flexible/), Cloudflare only attempts to connect to your origin web server via HTTP. This means that Cloudflare serves the same cached resource for visitor requests via either HTTP or HTTPS, since Flexible SSL instructs Cloudflare to connect to an origin solely over HTTP.
50
+
Cloudflare's`$scheme`variable plays a key role in caching behavior, but its meaning varies depending on the cache key type:
51
51
52
-
It is important to understand how SSL setting changes affect the cache:
52
+
-**Default Cache Key**: `$scheme` refers to the **origin scheme** — the protocol Cloudflare uses to connect to your origin server (HTTP or HTTPS). In this configuration, changes to your SSL settings (for example, switching from Flexible to Full) alter the origin scheme. Because the cache key includes the origin scheme, such changes trigger a cache bust, requiring Cloudflare to fetch content again from the origin.
53
53
54
-
-Switching from **Off**to **Full**,**Full (strict)**, or **Strict** will change the origin scheme from HTTP to HTTPS. This results in a cache bust, meaning the cached content becomes invalid and needs to be re-fetched from the origin server.
54
+
-**Custom Cache Key**: `$scheme` refers to the**visitor's scheme** — the protocol used by the client making the request to Cloudflare. In this case, SSL setting changes do not impact the cache key unless the origin scheme is explicitly included in your custom configuration.
55
55
56
-
- Transitioning from **Flexible**to **Full**, **Full (strict)**, or **Strict** changes the origin scheme from HTTP to HTTPS, causing a cache bust.
56
+
For example, with Flexible SSL, Cloudflare always connects to the origin over HTTP, regardless of whether the visitor uses HTTP or HTTPS. This results in the same cache key for both protocols under the default configuration.
57
57
58
-
- Downgrading from **Full**, **Full (strict)**, or **Strict** to **Flexible** or **Off**changes the origin scheme from HTTPS to HTTP, resulting in a cache bust.
58
+
Be aware that changes in the SSL setting can lead to cache invalidation when using the default cache key:
59
59
60
-
This behavior is important to consider when adjusting SSL settings, as any change in the origin scheme (HTTP to HTTPS or vice versa) triggers a cache reset.
60
+
- Switching from **Off** to **Full**, **Full (strict)**, or **Strict** updates the origin scheme from HTTP to HTTPS, resulting in a cache bust.
61
+
62
+
- Moving from **Flexible** to **Full**, **Full (strict)**, or **Strict** similarly changes the origin scheme to HTTPS and causes a cache bust.
63
+
64
+
Understanding how $scheme interacts with your caching configuration is essential when modifying SSL modes to avoid unexpected cache behavior.
61
65
62
66
#### Visitor scheme vs Origin scheme in Cache Keys
0 commit comments