All Products
Search
Document Center

Dynamic Content Delivery Network:Configure static file types

Last Updated:Jan 02, 2024

To accelerate the delivery of static and dynamic resources, you can enable the dynamic acceleration feature and create custom acceleration rules for static resources by configuring static file types. This way, static resources are no longer accelerated by the dynamic acceleration feature. This allows you to cache static resources on points of presence (POPs) and retrieve dynamic resources from the origin server over an optimal route.

Background information

The following acceleration rules take effect on static and dynamic resources:

  • On

    To accelerate the delivery of static and dynamic resources, you need to enable the Dynamic Acceleration feature. You can configure acceleration rules for static resources by file type based on your business requirements. Then, static resources are distributed based on the custom acceleration rules. You can also configure the URIs and directories of static resources that can be cached on POPs.

  • Off

    If you no longer need to accelerate the delivery of dynamic resources, you can disable the Dynamic Acceleration feature. After you disable the dynamic acceleration feature, dynamic resources are distributed based on static content cache rules without acceleration. Only the default static file acceleration rules are valid. All custom static file acceleration rules become invalid.

Procedure

  1. Configure static file types.

    1. Log on to the DCDN console.

    2. In the left-side navigation pane, click Domain Names.

    3. On the Domain Names page, find the domain name for which you want to configure static file types and click Configure.

    4. In the left-side navigation tree of the domain name, click Acceleration Rules.

    5. Turn on Dynamic Acceleration.

    6. On the Static File Types tab, click Modify.

    7. In the Static File Types dialog box, enable or disable Adaptive Caching and configure the Static File Types parameter. The following table describes the parameters.

      静态文件类型

      Parameter

      Description

      Adaptive Caching

      You can perform adaptive caching based on acceleration rules for static resources by file type. Adaptive caching takes effect based on the following priorities:

      • Priority 1: If you have configured Static File Types and Cache Expiration, the configurations of Static File Types and Cache Expiration take effect, regardless of whether you enable Adaptive Caching.

        Note

        Make sure that the filename extensions that you specify in Cache Expiration are included in Static File Types. Otherwise, the cache rules that are specified in Cache Expiration do not take effect.

      • Priority 2: If you enable Adaptive Caching and do not configure the Static File Types or Cache Expiration, the cache rules that are configured on the origin server take effect, and the system caches files to the maximum extent. If you want to cache a large number of files, we recommend that you configure Static File Types and Cache Expiration for better performance.

      • If you do not enable Adaptive Caching or configure Cache Expiration, the cache rules that are configured on the origin server take effect.

      Static File Types

      The following types of static files are supported:

      • Images: GIF, PNG, BMP, JPEG, and JPG.

      • Web pages: HTML, HTM, and SHTML.

      • Audio and video files: MP3, WMA, FLV, MP4, WMV, OGG, and AVI.

      • Text files: DOC, DOCX, XLS, XLSX, PPT, PPTX, TXT, and PDF.

      • Others: ZIP, EXE, TAT, ICO, CSS, JS, SWF, APK, M3U8, TS, EJS, SVG, WOFF, and OTF.

    8. Click OK.

  2. Create a cache expiration rule.

    1. In the Cache Expiration section, click Add.

    2. In the Cache Duration dialog box, select Directory or Filename Extension for the Type parameter and configure other required parameters.

      配置缓存过期时间

      Parameter

      Description

      Type

      Select Directory or Filename Extension.

      • Directory: Create a cache rule for the resources in the specified directory.

      • Filename Extension: Create a cache rule for resources that have the specified filename extension.

      Content

      Specify the directories or filename extensions for which you want to create the cache rule.

      • If you select Directory, take note of the following rules:

        • You can enter only one directory at a time. You can use a forward slash (/) to specify all directories.

        • You can enter a full path. The path must start with a forward slash (/), for example, /directory/aaa.

      • If you select Filename Extension, take note of the following rules:

        • You can enter one or more filename extensions. Separate the filename extensions with commas (,). Example: jpg,txt. Filename extensions are case-sensitive.

          The following types of static files are supported:

          • Images: GIF, PNG, BMP, JPEG, and JPG.

          • Web pages: HTML, HTM, and SHTML.

          • Audio and video files: MP3, WMA, FLV, MP4, WMV, OGG, and AVI.

          • Text files: DOC, DOCX, XLS, XLSX, PPT, PPTX, TXT, and PDF.

          • Others: ZIP, EXE, TAT, ICO, CSS, JS, SWF, APK, M3U8, TS, EJS, SVG, WOFF, and OTF.

        • You cannot use the asterisk wildcard character (*) to specify all file types.

      Expire In

      The cache duration for cached resources. The maximum cache duration is three years. If you specify a cache duration, take note of the following rules:

      • Specify a cache duration of one month or longer for static files that are infrequently updated, such as images and application packages.

      • Specify a cache duration based on your business requirements for static files that are frequently updated, such as JS and CSS files.

      • We recommend that you specify a cache duration of 0 seconds to disable caching for dynamic files, such as PHP, JSP, and ASP files.

      Weight

      Specify a weight for the cache rule. The weight indicates the priority of the cache rule. Valid values: 1 to 99. A larger value specifies a higher priority.

      Note
      • If you create multiple cache rules, we recommend that you specify a unique weight for each cache rule to define the priorities of the cache rules.

      • Cache rules that have the same weight are prioritized based on the creation time, regardless of the rule type. The rule that has the earliest creation time takes precedence.

      • If you have configured multiple cache rules for a cached resource, only the first matched rule takes effect.

    3. Click OK.