请选择
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

Content Cache Rules

Overview

After a client initiates an HTTP request to an EdgeOne node, if the requested file is not found in the cache, EdgeOne initiates a request to the origin to obtain the latest version of the file. After the origin returns the requested file, EdgeOne caches the file based on the default cache policy and your custom rules (See Node Cache TTL. Cache rules take effect in the following order:



Note:
A cache rule takes effect only if the origin returns 200 or 206. If the origin returns 404, the node caches the status code for 10s, and other status codes are not cached.
1. Rules configured in the rule engine are first matches the file against the cache rules in the rule engine from top to bottom. If the file matches a cache rule in the rule engine, it is cached as per that rule.
2. If the file does not match any rule in the rule engine, it is cached as per the global cache policy specified in Site Acceleration. EdgeOne uses the global cache policy as the default cache policy. You can modify the default cache policy as needed.

Cache Rules

EdgeOne supports the following three types of cache policies:
Default cache policy: The default cache policy of EdgeOne. The default cache policy determines the cache time of a file on a node based on the Cache-Control header and other caching-related headers of the HTTP response.
No-cache policy: Rules are set in the rule engine to specify not to cache specified files or not to cache any files of the site. A no-cache policy is applicable to dynamic or frequently updated files.
Custom cache policy: A custom cache policy allows you to cache files for a custom period of time.
Note:
EdgeOne supports cold file eviction. If a file cached in an EdgeOne node has not been requested over a long period of time, EdgeOne may remove it from the node cache before the specified cache time expires.

Default cache policy

The following figure describes the default cache policy of EdgeOne:



The default cache policy allows an EdgeOne node to control the caching of the file based on the following cache rules:
1. When the HTTP response contains any of the following not-to-cache headers, the file is not cached:
Cache-Control:private
Cache-Control:no-store
Cache-Control:no-cache
2. When the HTTP response header contains any of the following to-cache headers, the file is cached for the period of time specified in the header:
Cache-Control:s-maxage
Cache-Control:max-age
Expires
If more than one of the preceding response headers exists at the same time, their precedence is as follows: s-maxage > max-age > Expires. The file is cached for the period of time specified by the header with the highest priority.
3. When the HTTP response does not contain any of the preceding caching-related headers, the caching action specified in the rule is performed:
Default cache policy:
If the HTTP response contains the Last-Modified header, the cache time is calculated by this formula: (Current time - Value of Last-Modified) × 0.1. If the result ranges from 10 to 3,600 seconds, the result is taken as the cache time. If the result is less than 10 seconds, 10 seconds is taken as the cache time. If the result is greater than 3,600 seconds, 3,600 seconds is taken as the cache time.
If the HTTP response does not contain the Last-Modified header, the cache time of a file is determined based on the default cache rules and the file extension. The following table describes the cache time of files with different extensions:
Table 1: Default cache time for different file types
File Type
Extension
Cache Time
Dynamic files
php, aspx, asp, jsp, do, dwr, cgi, fcgi, action, ashx, axd, and json
Do not cache the file
Static files
Images
jpg, png, jpeg, webp, gif, heif, heic, kpg, and ico
2 hours
Audio/Video
mp4, mp3, m3u8, ts, m4a, avi, m4s, and ogg
Webpages
html, js, and css
Packages
zip, 7z, tar, br, gz, rar, and bz2
Documents
doc, docx, xls, xlsx, pdf, ppt, and pptx
Applications
apk, exe, and bin
Others
vsv, iso, jar, swf, chunk, and atlas
Other files
N/A
Do not cache the file
No Cache: If the HTTP response does not contain any of the preceding caching-related headers, the file is not cached.
Custom cache policy: If the HTTP response does not contain any of the preceding caching-related headers, the file is cached for the cache time specified in the custom rule.

No-cache policy

If the no-cache policy is set for the EdgeOne rule engine or the entire site, the file is not cached regardless of whether the HTTP response contains the Cache-Control header or other caching-related headers.

Custom cache policy




A custom cache policy allows you to cache a file for a custom period of time, and enable or disable the force cache feature.
Enable force cache: Force cache is enabled by default. If force cache is enabled, EdgeOne caches the file for the custom period of time, regardless of whether the HTTP response contains the Cache-Control header or other caching-related headers.
Disable force cache: After you disable force cache, if the HTTP response contains any of the following not-to cache headers, the file is not cached:
Cache-Control:private
Cache-Control:no-store
Cache-Control:no-cache
If the HTTP response does not contain any of the preceding headers, EdgeOne caches the file for the custom period of time.

Learn More