To accelerate the delivery of both dynamic and static resources, you can enable the dynamic acceleration feature. You can customize acceleration rules for static resources by configuring static file types. In this case, static files no longer use dynamic acceleration. This allows you to cache static resources to edge nodes and use the optimal routing to retrieve dynamic resources from the origin server.

Background information

The following acceleration rules are applicable to both dynamic and static resources:
  • Enable dynamic acceleration

    To accelerate the delivery of static and dynamic resources, you must turn on Dynamic Acceleration. You can configure acceleration rules for static file types based on your business requirements. Then, the delivery of static and dynamic resources is accelerated based on these custom acceleration rules. You can customize the file types, the Uniform Resource Identifiers (URIs), and the directories of static resources that can be cached on DCDN cache nodes.

  • Disable dynamic acceleration

    If you do not need to accelerate the delivery of dynamic resources, you can turn off Dynamic Acceleration. After dynamic acceleration is disabled, the dynamic resources are delivered without acceleration. Static resources are delivered based on edge cache rules. Only the default static file acceleration rules are valid. All custom static file acceleration rules become invalid.

Procedure

  1. Configure the 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 that you want to manage and click Configure in the Actions column.
    4. The details page of the specified domain name appears. In the left-side navigation pane, 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, choose to enable or disable Adaptive Caching, and then configure Static File Types.
      Static file types
      Parameter Description
      Adaptive Caching You can configure the adaptive cache settings based on the static file type and the cache rule of the origin server.
      • Enable Adaptive Caching
        If you enable adaptive caching, rules in Static File Types take lower priority than those of adaptive caching. All cache rules that are configured for Cache Expiration in the DCDN console take effect. The following priorities are supported:
        • Priority 1: If you have configured Cache Expiration in the DCDN console, the cache rules configured in Cache Expiration apply.
        • Priority 2: If no cache rules are configured for the Cache Expiration setting in the DCDN console, the cache rules that are configured on the origin server apply.
        • Priority 3: If no cache rules are configured in the DCDN console or on the origin server, DCDN dynamically initiates back-to-origin requests.
      • Disable Adaptive Caching
        • If you disable adaptive caching and have configured Static File Types and Cache Expiration in the DCDN console, the rules of Cache Expiration configured in the DCDN console apply.
          Note Make sure that the file name extensions specified in Cache Expiration are included in Static File Types. Otherwise, the cache rules configured in Cache Expiration do not take effect.
        • If you disable adaptive caching and have configured Static File Types but have not configured Cache Expiration, rules that are configured on the origin server apply.
      Static File Types
      The following static file types 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, and TS.
    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 specify the other parameters for the cache rule.
      Create a cache expiration rule
      Parameter Description
      Type
      • Directory: specifies the resources cached in the specified directory.
      • Filename Extension: specifies the resources that are cached in files with the specified file extensions.
      Content
      • If you select Directory, enter a directory name in the Content field. The directory name must start with a forward slash (/), such as /directory/aaa.
      • If you select Filename Extension, enter one or more file extensions in the Content field. Separate multiple file extensions with commas (,), such as JPG,TXT.
        The following static file types 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, and TS.
      Expire In Set a TTL value for the cached resources. A DCDN node can retain the cached resources for up to three years. We recommend that you set this parameter based on the following rules:
      • Specify a TTL value of one month or longer for static files that are not frequently updated, such as images and packages for application downloads.
      • Specify a TTL value based on your actual workloads for static files that are frequently updated, such as JavaScript and CSS files.
      • Specify a TTL value of zero seconds to disable caching for dynamic files, such as PHP, JSP, and ASP files.
      Weight Set the priority of the cache expiration rule.
      Note
      • The value must be an integer that ranges from 1 to 99. A higher value indicates a higher priority. Rules with higher priorities take precedence over rules with lower priorities.
      • We recommend that you set different priorities for different rules. If different rules have the same priority, one of these rules is randomly applied.
      For example, if you set the following rules for example.aliyun.com, Rule 1 takes priority over the other two rules.
      • Rule 1: Filename Extension is selected for Type, Content is set to jpg,png, Expire In is set to 1 month, and Weight is set to 90.
      • Rule 2: Directory is selected for Type, Content is set to /www/dir/aaa, Expire In is set to 1 hour, and Weight is set to 70.
      • Rule 3: Directory is selected for Type, Content is set to /www/dir/aaa/example.php, Expire In is set to zero seconds, and Weight is set to 80.
    3. Click OK.