Edge Acceleration
  • Site Acceleration
    • Overview
    • Quickly Import and Export Site Configuration
    • Access Control
      • Token Authentication
    • Smart Acceleration
    • File Optimization
      • Smart Compression
    • Network Optimization
      • HTTP/2
      • HTTP/3(QUIC)
        • Overview
        • Enable HTTP/3
        • QUIC SDK
          • SDK Overview
          • SDK Download and Integration
          • Sample Code
            • Android
            • iOS
          • API Documentation
            • Android
            • iOS
      • IPv6 Access
      • Maximum Upload Size
      • WebSocket
      • Client IP Geolocation Header
      • Client IP Geographical Location
      • gRPC
    • URL Rewrite
      • Access URL Redirection
      • Origin-Pull URL Rewrite
    • Modifying Header
      • Modifying HTTP Response Headers
      • Modifying HTTP Request Headers
    • Custom Error Page
    • Request and Response Actions
      • Processing order
      • Default HTTP Headers of Origin-Pull Requests
      • Default HTTP Response Headers
    • Media Services
      • Audio and Video Pre-pulling
      • Just-in-Time Image Processing
      • Just-in-Time Media Processing
      • VOD Media Origin
  • L4 Proxy
    • Overview
    • Creating an L4 Proxy Instance
    • Modifying an L4 Proxy Instance
    • Disabling or Deleting an L4 Proxy Instance
    • Batch Configuring Forwarding Rules
    • Obtaining Real Client IPs
      • Obtaining Real TCP Client IPs via TOA
      • Obtaining Real Client IPs Through Protocol V1/V2
        • Overview
        • Method 1: Obtaining Real Client IPs Through Nginx
        • Method 2: Parsing Real Client IPs on Application Server
        • Format of Real Client IPs Obtained Through Proxy Protocol V1/V2
      • Transmitting Client Real IP via SPP Protocol
  • Edge DNS
    • Hosting DNS Records
      • Modifying DNS Servers
      • Configuring DNS Records
      • Advanced DNS Configuration
    • Domain Connection
      • Adding A Domain Name for Acceleration
      • Ownership Verification
      • Modifying CNAME Records
    • Domain alias
      • Overview
      • Configuration Guide
      • Batch Connecting SaaS Domain Names
      • Configuring Alias Domain Names for Disaster Recovery
    • Traffic Scheduling
      • Traffic Scheduling Management
    • Origin Configuration
      • Origin-pull configuration
        • Configuring Origin-Pull HTTPS
        • Host Header Rewrite
        • Controlling Origin-pull Requests
        • Redirect Following During Origin-Pull
        • HTTP/2 Origin-Pull
        • Range GETs
      • Load Balancing
        • Overview
        • Quickly Create Load Balancers
        • Health Check Policies
        • Viewing the Health Status of Origin Server
        • Related References
          • Load Balancing-Related Concepts
          • Introduction to Request Retry Strategy
      • Origin Group Configuration
      • Related References
        • ld Version Origin Group Compatible Related Issues
      • Collect EdgeOne origin-pull node IP
  • Edge Cache
    • Overview
    • EdgeOne Cache Rules
      • Content Cache Rules
      • Cache Key Introduction
      • Vary Feature
    • Cache Configuration
      • Custom Cache Key
      • Node Cache TTL
      • Status Code Cache TTL
      • Browser Cache TTL
      • Offline Caching
      • Cache Prefresh
    • Clear and Preheat Cach
      • Cache Purge
      • URL Pre-Warming
    • How to improve the Cache Hit Rate of EdgeOne
  • Rules Engine
    • Overview
    • Supported Matching Types and Actions
    • Rule Management
    • variables

Custom Cache Key

Feature Introduction

When you need to point the Request URL of the same path to different files based on request parameters, cookies, or HTTP request headers, or point the Request URL with different parameters to the same file, the custom Cache Key supports customizing the Cache Key identification of resources in the node, including concatenating query strings, concatenating HTTP headers or Cookie information, etc., so that the Request URL can correctly obtain the corresponding cached resources according to different scenarios. You can learn what a Cache Key is through the Cache Key Introduction.

Usage Scenarios

Scenario One: The file paths accessed by users are exactly the same, but there will be version differences based on the carried query strings, HTTP request headers, and Cookie contents. The cache key of this type of file can be adjusted by customizing the Cache Key.
Scenario Two: The content of the query string in the user's accessed URL does not affect the file content, and the files corresponding to the above requests are consistent and do not affect the file version. The cache key of this type of file can be adjusted by customizing the Cache Key.

Directions

Scenario One: Configure custom Cache Key for all domain names of the site

If you need to configure a custom Cache Key for the entire connected site, or as a site-level fallback configuration, please refer to the following steps:
1. Log in to the EdgeOne console and click Site List in the left sidebar.In the site list, click the target Site.
2. On the site details page, click Site Acceleration to enter the Site Global Configuration page. In the right-hand navigation bar, click Cache Configuration.
Note:
Global configuration can only configure query strings and case-insensitive. For more comprehensive custom Cache Key configuration options, please refer to the configuration steps in Scenario Two's rule engine.
On the cache configuration page, locate the Query string card and click Global settings to proceed with the configuration.

The default configuration is to retain all, that is, to retain all query parameters of the original Request URL as the Cache Key. Other options are available: a. Ignore all: Ignore the entire query string; b. Reserve Specified Parameter: Only retain the specified parameters in the query string; c. Ignore specified parameter: Only ignore the specified parameters in the query string.

On the cache configuration page, find the Case-Insensitive Card. The default configuration is disabling the Ignore case. Even if the URL's content is the same, but the letter case is different, it will be regarded as a different Cache Key. Click the Global Enable switch to turn on the Ignore case, then different letter cases will be regarded as the same Cache Key.


Scenario Two: Configure custom Cache Key for specific domain names, paths, or file extensions, etc.

If you need to configure a custom Cache Key rule for the www.example.com domain under the site example.com to ignore all query strings, concatenate the HTTP request header My-Client-Header, and use the parameters name1 and name2 in the Cookie as the Cache Key, you can refer to the following steps for configuration:

Directions

1. Log in to the EdgeOne console, and click Site List in the left sidebar.In the site list, click the target Site.
2. On the site details page, click Site Acceleration to enter the global site configuration page, then click the Rule Engine tab.
3. On the rule engine management page, click Create rule and select Add blank rule.
4. On the rule editing page, select Host as the matching type and configure it as www.example.com.
5. Click on the Action, and in the pop-up operation list, select the operation as Custom Cache Key;
6. Click on Add under the Type to add the custom Cache Key type. In this example scenario, add Query String, HTTP Request Header, and Cookie for configuration and fill in the corresponding content. The complete rule configuration is as follows:

7. Click Save and Publish to complete the rule configuration.

Effective Example

After the configuration is completed, the Cache Key is composed of URL+My-Client-Header+Cookie: Ignore all query strings, concatenate My-Client-Header, and retain the specified parameters in the Cookie.
Then Client A request:
URL: https://www.example.com/path/demo.jpg?key1=value1&key2=value2
HTTP request header: Contains My-Client-Header:fruit
Cookie: name1=yummy;name2=tasty;name3=strawberry
And Client B request:
URL: http://www.example.com/path/demo.JPG?key1=value1&key2=value2&key3=value3
HTTP request header: Contains My-Client-Header:fruit
Cookie: name1=yummy;name2=tasty;name3=blueberry
And Client C request:
URL: http://www.example.com/path/demo.JPG?key1=value1&key2=value2&key3=value3&key4=value4
HTTP request header: Contains My-Client-Header:sea
Cookie: name1=yummy;name2=tasty;name3=fish
Requests A and B will hit the same cached resource, while C will hit another cached resource.

Related Reference

Description of supported header names:
Header Type
Description
Custom Header
Custom Headers.
Name: 1 - 100 characters, consisting of digits 0 - 9, letters a - z, A - Z, and the special character -.
Value: 1 - 1000 characters, Chinese is not supported.
Preset Header
Aggregated headers based on client User-Agent information:
Client Device Type: EO-Client-Device
Values: Mobile, Desktop, SmartTV, Tablet, or Others
Client Operating System: EO-Client-OS
Values: Android, iOS, Windows, MacOS, Linux, or Others
Client Browser Type: EO-Client-Browser
Values: Chrome, Safari, Firefox, IE, or Others