All Products
Search
Document Center

ApsaraVideo VOD:Configure HTTP response headers

Last Updated:Jun 18, 2026

When the cache on a CDN/ point of presence (POP) expires or a cache miss occurs, the CDN/ POP requests the latest content from the origin server. The content and HTTP headers returned by the origin server are called origin response headers. You can modify these headers on your origin server to define a cache policy, configure Cross-Origin Resource Sharing (CORS), and more. This allows you to optimize website loading speed, enhance content security, control resource accessibility, and improve the user experience.

Background

HTTP response headers are components of an HTTP response that carry specific parameters to the client.

When content requested by an end user is not cached on a CDN node, the CDN performs an origin fetch, and the origin server sends a response. You can modify the HTTP headers in this inbound response. For example, you can rewrite the value of the Content-Type header before it is passed to the client to ensure proper parsing. If the origin server returns an incorrect Content-Type value, the client may fail to parse the content correctly. You can resolve this issue by rewriting the header on the CDN.

Note
  • An inbound response is the HTTP message that an origin server sends to a CDN node. Modifying inbound response headers only affects the HTTP message sent from the origin server to the CDN node; it does not affect responses the CDN node serves to the end user.

  • You cannot modify inbound response headers for wildcard domains.

Procedure

  1. Log on to the ApsaraVideo VOD console.

  2. In the left-side navigation pane, choose Configuration Management > CDN Configuration > Domain Names.

  3. Find the domain name you want to manage and click Configure in the Actions column.

  4. In the left navigation pane for the domain name, click Back-to-Origin.

  5. Click the Origin HTTP Response Headers tab.

  6. Click Add and configure the back-to-origin HTTP response header.

    Important

    If multiple operations apply to the same origin response header parameter, the operations are executed based on the following priority: Replace > Add > Change and Delete. For example, if both an add and a delete operation are configured for the same parameter, the add operation is executed before the delete operation.

    Add response header

    Parameter

    Example

    Description

    Operation

    add

    Adds the specified response header to the origin response.

    Response Header

    Custom Response Header

    Select Custom Response Header or a preset response header parameter.

    Header Name

    x-code

    Specifies the name of the custom response header.

    Header Value

    key1

    Enter one or more header values, separated by commas (,).

    key1,key2

    Allow Duplicates

    Allow

    • Yes: Allows you to add duplicate response headers. For example, x-code:key1 and x-code:key2.

    • No: If a header with the same name already exists, the new value overwrites the existing one. For example, if you add x-code:key1 and then x-code:key2, the final header is x-code:key2.

    Rule Condition

    Do not use

    A rule condition allows a rule to be applied only when a request meets specific criteria.

    • Do not use: Disables conditional rules.

    • You can add or edit conditional rules in the Rules engine.

    Delete response header

    Parameter

    Example

    Description

    Operation

    delete

    Removes all response headers that have the specified name, including duplicates.

    Response Header

    Custom Response Header

    Select Custom Response Header or a preset response header parameter.

    Header Name

    x-code

    Specifies the name of the custom response header to delete.

    Rule Condition

    Do not use

    A rule condition allows a rule to be applied only when a request meets specific criteria.

    • Do not use: Disables conditional rules.

    • You can add or edit conditional rules in the Rules engine.

    Modify response header

    Parameter

    Example

    Description

    Operation

    modify

    Modifies the header. This operation is not allowed if duplicate headers with the same name exist.

    Response Header

    Custom Response Header

    Select Custom Response Header or a preset response header parameter.

    Header Name

    x-code

    Specifies the name of the custom response header to modify.

    Change Value To

    key1,key3

    Specifies the new value for the header. To configure multiple values, separate them with commas (,).

    Rule Condition

    A rule condition allows a rule to be applied only when a request meets specific criteria.

    • Do not use: Disables conditional rules.

    • You can add or edit conditional rules in the Rules engine.

    Replace response header

    Parameter

    Example

    Description

    Operation

    replace

    Replaces the header value. This operation is not allowed if duplicate headers with the same name exist.

    Response Header

    Custom Response Header

    Select Custom Response Header or a preset response header parameter.

    Header Name

    x-code

    Specifies the name of the custom response header whose value you want to replace.

    Find

    key

    A regular expression that matches the part of the header value to replace.

    Replace With

    abc

    The value that replaces the matched text.

    Match

    Match All

    • Match All: Replaces all occurrences that match the regular expression. For example, if the header is x-code:key1,key2,key3 and you use a regular expression to replace the matched value key with abc, the result is x-code:abc1,abc2,abc3.

    • Match the First Only: Replaces only the first occurrence that matches the regular expression. For example, if the header is x-code:key1,key2,key3 and you use a regular expression to replace the matched value key with abc, the result is x-code:abc1,key2,key3.

    Rule Condition

    -

    A rule condition specifies the criteria that a user request must meet for this configuration to apply.

    • Do not use: No rule condition is used.

    • To add or edit rule conditions, go to the rule engine page.

  7. Click OK to complete the configuration.

Configuration examples

Example 1: Set a response MIME type

Use case

Set a specific MIME type for a response.

Note

MIME types include the following main categories:

  • Text: Includes text files (such as .txt and .csv) and HTML files (such as .html, .htm, and .shtml).

  • Image: Includes common image files (such as .jpg, .png, and .gif).

  • Audio: Includes audio files (such as .mp3 and .wav).

  • Video: Includes video files (such as .mp4 and .avi).

  • Application: Includes application files (such as .pdf, .doc, and .xls).

Configuration

  • Response header operation: Add

  • Header name: Content-Type

  • Header value: text/html

    Set Allow Duplicates to Do not allow and Rule Condition to Do not use, then click OK.

Result: The POP adds the Content-Type: text/html header to the response from the origin server. If you configure this header again, the new value overwrites the existing one.

Example 2: Delete a response header

Use case

Deleting a response header.

Configuration

  • Response header operation: Delete

  • Header name: Content-Type

    Set Allow Duplicates to Do not allow and Rule Condition to Do not use, then click OK.

Result: The POP removes the Content-Type header from the response before returning it to the client.

Note

If you apply the configurations from both Example 1 and Example 2, the system first adds and then deletes the Content-Type: text/html response header. As a result, the client receives the response without a specified MIME type.

References

Batch configure domain names