Ignore Parameters

更新时间:
复制 MD 格式

When you enable parameter ignoring, CDN edge nodes remove query parameters (the part after the ?) from request URLs. This allows requests with different parameters to hit the same cached copy, improving the cache hit ratio. This topic describes how to configure parameter ignoring, compares it with alternative features, and provides troubleshooting guidance for common issues.

Feature Comparison and Selection

  • Custom Cache Key conflicts with parameter ignoring. When parameter ignoring is enabled, edge nodes strip all parameters after ? in the URL, which invalidates any request parameter settings in your Custom Cache Key configuration. Disable parameter ignoring before using Custom Cache Key.

  • Custom Cache Key can replace parameter ignoring for cache key configuration and offers more comprehensive functionality. We recommend using it first. Configuration comparison:

    Scenario

    Parameter Ignoring Configuration

    Custom Cache Key Configuration

    Ignore all request parameters in the cache key

    Set Ignore Parameters to Yes and leave Retain Specified Parameters empty.

    Add a request parameter handling rule:

    • Action: Retain

    • Parameter name: Set to any non-existent parameter name, such as example-argument.

    Retain only request parameter key1 in the cache key

    Set Ignore Parameters to Yes and set Retain Specified Parameters to key1.

    Add a request parameter handling rule:

    • Action: Retain

    • Parameter name: key1

    Delete only request parameter key1 from the cache key

    Delete the parameter setting for key1.

    Add a request parameter handling rule:

    • Action: Delete

    • Parameter name: key1

  • Rewrite Origin Parameters can replace parameter ignoring for origin request rewriting and offers more comprehensive functionality. We recommend using it first.

Feature Overview

Ignore Parameters

Function

Scenarios

Removes query parameters (the part after ?) from request URLs so that requests with different parameters hit the same cache file. This improves the cache hit ratio and reduces back-to-origin traffic.

Enable parameter ignoring when URL parameters are unrelated to resource content (such as user UID, referral source, or promo codes). For example, these two requests access the same resource but carry different UIDs:

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

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

Without parameter ignoring, CDN edge nodes treat these as different resources and cannot share the same cache, requiring an origin fetch for each request. With parameter ignoring enabled, CDN edge nodes strip the parameters and use http://example.com/1.jpg to match the cache.

Note

URL signing takes precedence over parameter ignoring. Type A signing includes URL parameters in its signature. CDN performs authentication first and caches the replica only after successful validation.

Retain Origin Parameters

Function

Scenarios

Retains all original URL parameters during origin fetches to ensure the origin server receives critical user information.

When parameter ignoring is enabled, CDN edge nodes use the parameter-stripped URL for origin fetches by default. In the example above, both User A and User B would trigger an origin request to http://example.com/1.jpg, losing critical information like UID. Enabling Retain Origin Parameters ensures CDN uses the original URL for origin fetches, preserving parameters like UID for the origin server.

Procedure

  1. Log on to the CDN console.

  2. In the navigation pane on the left, click Domain Names.

  3. In the domain list, click the target domain name. In the navigation pane on the left, click Optimization to go to the performance optimization configuration page.

  4. Click Modify in the Ignore Parameters section. Select a mode and complete the configuration based on your needs.

  5. After completing the configuration, click OK to save.

Important
  • Switching modes clears existing configurations.

  • After modifying the parameter ignoring configuration, cached files on edge nodes do not update automatically. You must perform a URL refresh or directory refresh in the console to apply the new configuration and purge old cache. Otherwise, users might still access content cached under the old policy, causing access issues.

Mode: Retain Specified Parameters

Parameter

Description

Example

Ignore Parameters

  • Yes: Enable parameter ignoring to remove all parameters after ? in the URL.

    Note

    If you enable Ignore Parameters but leave Retain Specified Parameters empty, all parameters after ? are removed.

  • No: Disable parameter ignoring to retain all URL parameters.

Assume the original URL is http://example.com/1.jpg?key1=1&key2=2&key3=3. The results for each configuration are as follows:

  • Example 1, ignore all parameters, do not retain origin parameters:

    • Configuration: Ignore Parameters=Yes, Retain Specified Parameters empty, Retain Origin Parameters=No.

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

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

  • Example 2, retain specified parameters, do not retain origin parameters:

    • Configuration: Ignore Parameters=Yes, Retain Specified Parameters=key1, Retain Origin Parameters=No.

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

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

  • Example 3, ignore all parameters, retain origin parameters:

    • Configuration: Ignore Parameters=Yes, Retain Specified Parameters empty, Retain Origin Parameters=Yes.

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

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

  • Example 4, retain specified parameters, retain origin parameters:

    • Configuration: Ignore Parameters=Yes, Retain Specified Parameters=key1, Retain Origin Parameters=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

Enter parameter names to retain. You can specify up to 10 parameters, separated by commas (,).

Retain Origin Parameters

  • Yes: Retain all original URL parameters during origin fetches.

  • No: During origin fetches, include only parameters consistent with the cache hash key (that is, the retained parameters).

Rule Condition

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

Important

When a feature references rule conditions, the execution order follows the priority of the associated rule conditions, not the order of the feature configurations.

  • Do not use: Disables conditional rules.

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

Mode: Delete Specified Parameters

Parameter

Description

Example

Remove Specified Parameters

Enter parameter names to delete. You can specify up to 10 parameters, separated by spaces.

Assume the original URL is http://example.com/1.jpg?key1=1&key2=2&key3=3. The results for each configuration are as follows:

  • Example 1, delete specified parameters, do not retain origin parameters:

    • Configuration: Delete Specified Parameters=key1, Retain Origin Parameters=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, delete specified parameters, retain origin parameters:

    • Configuration: Delete Specified Parameters=key1, Retain Origin Parameters=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: Retain all original URL parameters during origin fetches.

  • No: During origin fetches, include only parameters consistent with the cache hash key (that is, the result after deleting specified parameters).

Rule Condition

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

Important

When a feature references rule conditions, the execution order follows the priority of the associated rule conditions, not the order of the feature configurations.

  • Do not use: Disables conditional rules.

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

FAQ

How do I troubleshoot business issues after enabling parameter ignoring?

After enabling parameter ignoring, CDN treats requests with different parameters as the same resource for caching. Do not globally ignore URL parameters if they fall into these categories:

  • User identity identifiers (such as UID, Token, Session ID): Ignoring them causes authentication failures or data leakage between users.

  • Dynamic content differentiation (such as version numbers ?v=1 or pagination ?page=2): Ignoring them returns incorrect cached content.

  • Origin processing instructions (such as OSS image processing parameters x-oss-process): Ignoring them disables processing and returns unprocessed original resources.

Troubleshooting and resolution:

  1. Delete or disable the Ignore Parameters configuration.

  2. After modifying the configuration, perform a cache purge (URL refresh or directory refresh) to clear old cache from edge nodes.

  3. If some parameters must be retained, use the Retain Specified Parameters mode to preserve critical parameters (such as x-oss-process or token).

Why does the parameter ignoring configuration not take effect after modification?

After modifying the parameter ignoring configuration, cached files on edge nodes do not update automatically. If access issues persist or back-to-origin traffic does not decrease, follow these steps:

  1. Confirm the configuration is saved: Log on to the CDN console, revisit the parameter ignoring configuration page, and verify the current settings match your expectations.

  2. Check for conflicts with Custom Cache Key: Parameter ignoring and Custom Cache Key cannot coexist. Enabling parameter ignoring invalidates request parameter settings in Custom Cache Key. Ensure both features are not enabled simultaneously.

  3. Perform a cache purge: The new configuration takes effect immediately, but existing cached files still use the old policy. You must perform a URL refresh or directory refresh on the Refresh and Prefetch Resources page to clear old cache and fully apply the new configuration.

  4. Verify the configuration: Use the command curl -I "full URL" to check the X-Cache field in the response header and confirm the cache hit status matches expectations.

How do I configure parameter ignoring when using OSS image processing or video snapshots?

When using OSS image processing (such as x-oss-process=image/resize,w_200) or video snapshot features, enabling parameter ignoring on your CDN domain causes the original resource and processed resource URLs to be cached as the same file, leading to incorrect content delivery.

Solution: In the CDN console parameter ignoring configuration, set the x-oss-process parameter to Retain Specified Parameters mode. This ensures URLs with image processing parameters are cached separately, avoiding conflicts with the original resource cache.

How can I use parameter ignoring to handle requests that bypass cache using URL parameters?

When attackers or crawlers add random meaningless parameters (such as ?timestamp=xxx or ?random=xxx) to request the same resource, CDN treats each parameterized request as a unique resource. This reduces cache hit ratio and spikes back-to-origin traffic.

Enable parameter ignoring (or configure it to ignore all parameters) so requests with different random parameters hit the same cache, effectively reducing origin pressure. For example, after enabling parameter ignoring, these requests hit the same cache:

  • http://example.com/page.html?t=123456

  • http://example.com/page.html?t=789012

  • http://example.com/page.html?random=abc

With parameter ignoring enabled, all these requests use http://example.com/page.html to match the cache, effectively mitigating cache-bypass attacks via URL parameters.

Why do different clients show inconsistent cache hit status (X-Cache shows MISS) after enabling parameter ignoring?

Possible causes:

  1. URL carries dynamic authentication parameters not ignored: If the URL includes parameters like auth_key with different values per request, CDN treats them as different resources even with parameter ignoring enabled (if the auth parameter isn't retained).

  2. First access to a node with no cache: The resource hasn't been cached on that specific edge node yet, so the first access always shows MISS.

  3. Differences in client request headers: Variations in headers like Accept-Encoding or User-Agent may trigger multiple cache replicas (for example, separate Gzip and non-Gzip versions).

  4. Conflict with Custom Cache Key, causing the configuration to be ineffective.

Troubleshooting method: Run curl -I "full URL" on the client and compare the X-Cache and X-Swift-CacheTime response headers to confirm cache status.

Solution: Verify that parameter ignoring is correctly configured (enabled and critical parameters set to retain) and ensure consistent client request header policies.

How can I control CDN to fetch the latest resources during phased releases or version updates using URL parameters?

If parameter ignoring is enabled, CDN cannot distinguish versions using URL parameters (such as ?v=1 or ?v=2). Use one of these approaches:

  • Approach 1 (recommended): Use versioned filenames (such as style.v2.css or app.v2.js) instead of relying solely on query parameters to ensure users get the latest content.

  • Approach 2: When releasing a new version, proactively call the CDN refresh API to purge old cache.