All Products
Search
Document Center

CDN:Ignore parameters

Last Updated:Nov 16, 2023

If you enable parameter filtering, points of presence (POPs) remove the parameters that follow the question mark (?) in request URLs. These parameters contain information such as the user identity and request source. The original URLs are used as the cache keys. This topic describes how to configure parameter filtering.

Overview

Note

The URL signing feature has a higher priority over the parameter filtering feature. The signature information that is generated by signing type A contains the parameters in an HTTP request. Alibaba Cloud CDN verifies the signature information before the POPs cache a copy of the requested resource. For more information about how to configure URL signing, see Configure URL signing.

  • Ignore parameters

    Description

    Scenario

    Alibaba Cloud CDN removes the parameters that follow the question mark (?) in request URLs so that requests that are destined for the same file but carry different URL parameters can hit the cache. Parameter filtering increases the cache hit ratio, reduces the origin fetch frequency, and accelerates file distribution.

    Some users append parameters after the question mark (?) in request URLs to pass information, such as the user ID (UID), request source, and recommendation code, to the origin server. In this case, these URLs carry different query strings even if the requests are destined for the same file.

    We recommend that you enable parameter filtering if the parameters that follow the question mark (?) in URLs are irrelevant to the requested resource. Examples:

    • Request from User A: http://example.com/1.jpg?uid=123***

    • Request from User B: http://example.com/1.jpg?uid=654***

    If the POP uses the original URLs from User A and User B, the requests cannot hit the same file in the cache. The requests must be redirected to the origin server.

    After you enable parameter filtering, the POP removes the UIDs that follow the question mark (?) in the request URLs. The final URL http://example.com/1.jpg is used to match the cache.

  • Retain parameters in back-to-origin requests

    Description

    Scenario

    The original URLs are redirected to the origin server so that key user information can be passed to the origin server.

    If you enable parameter filtering, POPs redirect the URLs that are processed by the parameter filtering feature to the origin server. In the preceding examples, the requests from User A and User B both use the URL http://example.com/1.jpg. The UIDs are not passed to the origin server during origin fetch.

    If you retain parameters in back-to-origin requests, POPs redirect the original URLs to the origin server so that the UIDs are passed to the origin server.

The parameter filtering feature can retain or remove specified parameters. The following figure shows the process of parameter filtering.

image

Procedure

  1. Log on to the Alibaba Cloud CDN 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 Manage in the Actions column.

    Domain Names
  4. In the left-side navigation pane of the domain name, click Optimization.

  5. In the Ignore Parameters section, click Modify. In the dialog box that appears, select a filter mode based on your business requirements and configure the parameters.

    Important

    If you switch to another filter mode, existing configurations are cleared.

    • Filtering Mode: Retain Specified Parameters

      Parameter

      Description

      Example

      Ignore Parameters

      • Yes: enables the parameter filtering feature. Parameters that follow the question mark (?) are removed from URLs.

        Note

        If you set the Ignore Parameters parameter to Yes and do not specify the Retain Specified Parameters parameter, all parameters that follow the question mark (?) are removed.

      • No: disables the parameter filtering feature.

      If the original URL is http://example.com/1.jpg?key1=1&key2=2&key3=3, the following examples show how the URL is processed based on different settings:

      • Example 1: removes all parameters and redirects the final URL to the origin server.

        • Parameter settings: Ignore Parameters is set to Yes, no value is specified for Retain Specified Parameters, and Retain Parameters when Back to Origin is set to No.

        • Cache key: http://example.com/1.jpg.

        • Origin URL: http://example.com/1.jpg.

      • Example 2: retains specified parameters and redirects the final URL to the origin server.

        • Parameter settings: Ignore Parameters is set to Yes, Retain Specified Parameters is set to key1, and Retain Parameters when Back to Origin is set to No.

        • Cache key: http://example.com/1.jpg?key1=1.

        • Origin URL: http://example.com/1.jpg?key1=1.

      • Example 3: removes all parameters and redirects the original URL to the origin server.

        • Parameter settings: Ignore Parameters is set to Yes, no value is specified for Retain Specified Parameters, and Retain Parameters when Back to Origin is set to Yes.

        • Cache key: http://example.com/1.jpg.

        • Origin URL: http://example.com/1.jpg?key1=1&key2=2&key3=3.

      • Example 4: retains specified parameters and redirects the original URL to the origin server.

        • Parameter settings: Ignore Parameters is set to Yes, Retain Specified Parameters is set to key1, and Retain Parameters when Back to Origin is set to Yes.

        • Cache key: http://example.com/1.jpg?key1=1.

        • Origin URL: http://example.com/1.jpg?key1=1&key2=2&key3=3.

      Retain Specified Parameters

      You can specify up to 10 parameters that you want to retain. Separate multiple parameters with commas (,).

      Retain Origin Parameters

      • Yes: retains all parameters in request URLs during origin fetch.

      • No: retains only specified parameters in request URLs during origin fetch. The parameters remain the same as those in the cache key.

      Rule Condition

      Rule conditions can identify parameters in a request to determine whether a configuration takes effect on the request.

      • Do not use conditions

      • Select the configured rule conditions in Rules Engine. For more information, see Rules engine.

    • Filter Mode: Remove Specified Parameters

      Parameter

      Description

      Example

      Remove Specified Parameters

      You can specify up to 10 parameters that you want to remove. Separate multiple parameters with commas (,).

      If the original URL is http://example.com/1.jpg?key1=1&key2=2&key3=3, the following examples show how the URL is processed based on different settings:

      • Example 1: removes specified parameters and redirects the final URL to the origin server.

        • Parameter settings: Remove Specified Parameters is set to key1, and Retain Parameters when Back to Origin is set to No.

        • Cache key: http://example.com/1.jpg?key2=2&key3=3.

        • Origin URL: http://example.com/1.jpg?key2=2&key3=3.

      • Example 2: removes specified parameters and redirects the original URL to the origin server.

        • Parameter settings: Remove Specified Parameters is set to key1, and Retain Parameters when Back to Origin is set to Yes.

        • Cache key: http://example.com/1.jpg?key2=2&key3=3.

        • Origin URL: http://example.com/1.jpg?key1=1&key2=2&key3=3.

      Retain Origin Parameters

      • Yes: retains all parameters in request URLs during origin fetch.

      • No: removes only specified parameters in request URLs during origin fetch. The parameters remain the same as those in the cache key.

      Rule Condition

      Rule conditions can identify parameters in a request to determine whether a configuration takes effect on the request.

      • Do not use conditions

      • Select the configured rule conditions in Rules Engine. For more information, see Rules engine.

  6. Click OK.