tencent cloud

Feedback

Content Cache Rules

Last updated: 2023-05-25 15:19:39

    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

    
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support