A CDN node may receive a request of which the URL contains a question mark (?) and parameters, for example, http://alibaba.com/content?a=10. In this case, the CDN node will determine whether to ignore these parameters when it retrieves the requested resource from the cache or the origin server. This topic describes how to filter parameters in URLs of requests that Alibaba Cloud CDN receives.

Background information

  • Parameter filtering is enabled.

    When a CDN node receives a request, the CDN node ignores the parameters following the question mark (?) in the URL. The CDN node caches only one version of the requested resource.

    • Most HTTP requests contain parameters. Content can still be retrieved from the origin when parameters with low priorities are ignored. After you enable parameter filtering, the cache hit ratio and delivery efficiency are improved.
    • If a parameter contains important information such as the file version, we recommend that you specify the parameter as a retained parameter. You can set up to 10 retained parameters. If the requested URL contains a retained parameter, the CDN node will retrieve content from the origin server based on the URL with the retained parameter.
    • Configure the parameter filtering feature to ignore parameters following the question mark (?) in the requested URLs. This feature can increase the CDN cache hit ratio. For example, when http://www. ****.com/1.jpg is accessed for the first time, Alibaba Cloud CDN cannot retrieve the requested resource from the cache. It needs to request the resource from the origin server. When http://www. ****.com/1.jpg? test1 is accessed, the parameters following the question mark (?) are ignored because parameter filtering is enabled. As a result, the requested resource can be directly retrieved from the cache of http://www. ****.com/1.jpg.
  • Parameter filtering is disabled.

    A CDN node caches a unique version of a requested resource for each URL that includes different parameters.

    After the parameter filtering feature is disabled, the requested resource can be retrieved from the cache only if the parameters following the question mark (?) in the URL are an exact match with the previously cached one. Exact matches can increase request accuracy. For example, when http://www. ****.com/1.jpg is accessed for the first time, Alibaba Cloud CDN cannot retrieve the requested resource from the cache. It needs to request the resource from the origin server. When http://www. ****.com/1.jpg? test1 is accessed, the parameters following the question mark (?) in the URL must be an exact match because parameter filtering is disabled. As a result, the CDN node cannot respond with the cached resource of http://www. ****.com/1.jpg. Instead, the CDN node needs to retrieve the requested resource of http://www. ****.com/1.jpg?test1 from the origin server.

The parameter filtering feature allows you to configure retained parameters or ignored parameters.
  • Retained parameters: You can specify one or more parameters to be retained. You must separate multiple parameters with commas (,). Unspecified parameters are not retained.
  • Ignored parameters: You can specify one or more parameters to be ignored. You must separate multiple parameters with space characters. Unspecified parameters are not ignored.
Note The URL signing feature takes priority over the parameter filtering feature. The signing information in type A contains the parameters of an HTTP request. Therefore, a CDN node must verify the signed URL of the request before it caches a version of the requested resource. For more information about how to configure URL signing, see Configure URL signing.

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 target domain name and click Manage.
  4. In the left-side navigation pane of the specified domain, click Optimization.
  5. On the Optimization page, specify the retained parameters or ignored parameters.
    • Retain parameters
      1. On the Retain Parameters section, click Modify.
      2. You can specify the retained parameters as needed. Filter Parameters
        Parameter Description
        Parameter Filtering Enable or disable the parameter filtering feature. After this feature is enabled, the parameters following the question mark (?) in the URL are ignored when the CDN node serves the requested resource from the cache or the origin server. This helps to increase the cache hit ratio.
        Retain Parameters Specify the parameters to be retained. Up to 10 parameters can be specified. Separate multiple parameters with commas (,). Unspecified parameters are not retained. Example: Enter x=1 in the Retain Parameters field for the URL http://www.abc.com/a.jpg?x=1.
        Retain Origin Parameters Specify whether to retain all parameters in a URL of a request when Alibaba Cloud CDN retrieves the requested resource from the origin server. After the Retain Origin Parameters switch is turned on, all parameters are retained during the back-to-origin process.

        Example description:

        The CDN node sends a request for http://www.abc.com/a.jpg? x=1 to the origin server with the parameter x=1. The CDN node then retrieves the resource and caches a version of the requested resource. When the CDN node receives a request of which the URL contains the x=1 parameter, it always returns the version of the resource that was previously cached for http://www.abc.com/a.jpg?x=1.

      3. Click OK.
    • Ignore parameters
      1. On the Ignore Parameters section, click Modify.
      2. You can specify the ignored parameters as needed. Filter Parameters dialog box
        Parameter Description
        Parameter Filtering Enable or disable the parameter filtering feature. After parameter filtering is enabled, the parameters following a question mark (?) in a requested URL are ignored when the CDN node serves the requested resource from the cache or the origin server.
        Ignore Parameters Specify the parameters to be ignored. Up to 10 parameters can be ignored. Separate multiple parameters with space characters. Unspecified parameters are not ignored. For example, enter x=1 in the Ignore Parameters field for the URL http://www.abc.com/a.jpg?x=1.
        Retain Origin Parameters Specify whether to retain all parameters in a URL when Alibaba Cloud CDN retrieves the requested resource from the origin server. After the Retain Origin Parameters switch is turned on, all parameters are retained during the back-to-origin process.

        Example description:

        When http://www.abc.com/a.jpg? x=1 is accessed for the first time, the x=1 parameter is ignored when the CDN node requests the resource from the origin server. Therefore, the CDN node caches the retrieved resource for http://www.abc.com/a.jpg . When http://www.abc.com/a.jpg?x=2 is accessed for the first time, the x=2 parameter is not ignored. Therefore, the CDN node cannot return the requested resource from the cache and needs to request the resource from the origin server. Then, the CDN node caches the retrieved resource for URL http://www.abc.com/a.jpg?x=2.

      3. Click OK.