Yandex Cloud
Search
Contact UsGet started
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
  • Pricing
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Cloud CDN
  • Getting started
    • All guides
      • Creating a resource
      • Copying configuration from one resource to another
      • Updating basic settings of a resource
      • Getting information about a resource
      • Configuring resource caching
      • Configuring log export
      • Prefetching files to CDN servers
      • Purging resource cache
      • Configuring request and response headers
      • Configuring CORS for responses to clients
      • Configuring HTTP methods
      • Enabling file compression
      • Enabling file segmentation
      • Enabling origin shielding
      • Configuring request redirection
      • Setting up access via a secure token
      • Setting up location rules
      • Managing additional resource settings
      • Disabling a resource
      • Managing resource labels
      • Deleting a resource
      • Viewing resource statistics
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics for the EdgeCDN provider
  • Monitoring metrics for the Yandex Cloud CDN provider
  • Audit Trails events
  • Release notes
  • Troubleshooting

In this article:

  • Creating a location rule
  • Configuring advanced settings
  • See also
  1. Step-by-step guides
  2. Resources
  3. Setting up location rules

Setting up Yandex Cloud CDN location rules

Written by
Yandex Cloud
Updated at December 3, 2025
  • Creating a location rule
  • Configuring advanced settings
    • See also

Warning

The location rule functionality is only available through the Yandex Cloud CDN provider.

Location rules are a mechanism used to selectively redefine CDN resource settings for requests whose paths match a specific template.

Let’s assume that content caching is enabled in the CDN resource settings, while cache lifetime is set to four days. This is enough for most types of content, but for some specific files you have to reduce cache lifetime to a few seconds. Location rules will help you with such cases.

Learn more about location rules

To set up a location rule:

  1. Create a rule.
  2. Configure advanced settings.

Creating a location ruleCreating a location rule

Management console
API
  1. In the management console, select the folder where your resource is located.

  2. Go to Cloud CDN.

  3. Click the CDN resource name.

  4. Select the Location rules tab.

  5. In the top-right corner, click Add rule.

  6. Under Overview, configure the main location rule settings:

    • Name.

      The rule name may contain lowercase Latin letters, numbers, underscores, hyphens, and spaces, and may be up to 50 characters long.

    • Rule weight: Rule triggering priority. The lower a rule’s weight, the higher its priority in the user resource configuration. If multiple rules have the same weight, they will be applied in a random order.


      For example, let’s assume you set the following location rules:

      Rule Weight Regular expression Cache lifetime
      A 1 ^/path/.+ 1 hour
      B 2 \.txt$ 4 hours

      With this configuration, the /path/file.txt request will match rule A, which has a lower weight and a higher priority than rule B, so the file will be cached for one hour.

      To cache the /path/file.txt file for four hours, rule B must have a lower weight than rule A.

  7. Under Condition, set Regular expression, i.e., the URI path pattern against which requests are checked. If there is a match, the settings specific to that location rule will apply.

    Tip

    To explicitly indicate the start or end of the string to match in a regular expression, use the ^ and $ anchor characters.

  8. Specify the CDN resource settings you want to redefine using a location rule:

    • CDN caching: Temporary storage of file copies from origins. For more information, see Configuring resource caching.
    • Redirect requests: Redirecting content requests to a different path. This is useful when rearranging files and folders on an origin. You can also use redirection if you want to keep search engine rankings of your content when moving your resource to a new address. For more information, see Configuring request redirection.
    • Access via secure token: Restricting direct access to content via pre-signed URLs with the limited validity period. For more information, see Setting up access via a secure token.
    • IP-based access: Restricting access to content using an allowing or blocking policy. For more information, see Updating the basic settings of a resource.

    Note

    The settings of HTTP headers and methods, CORS, content compression and segmentation, as well as advanced content caching options, become available after you create a location rule. For more details, see Setting additional parameters.

  9. Click Create.

Use the create REST API method for the ResourceRules resource or the ResourceRulesService/Create gRPC API call.

Configuring advanced settingsConfiguring advanced settings

After creating a rule, you can configure its advanced settings:

Management console
API
  1. In the management console, select the folder where your resource is located.

  2. Go to Cloud CDN.

  3. Click the CDN resource name.

  4. Select the Location rules tab.

  5. Click the location rule name.

  6. Configure advanced rule settings:

    • To set up advanced content caching options, go to the Caching tab and click Edit. For more information, see Configuring resource caching.
    • To configure HTTP request and response headers, CORS for responses to clients, and allowed HTTP methods for client requests, go to the HTTP headers and methods tab and click Edit. For more information, see:
      • Configuring HTTP headers of requests and responses
      • Configuring CORS for responses to clients
      • Configuring HTTP methods
    • To configure file compression and segmentation, go to the Content tab and click Edit. For more information, see:
      • Enabling file compression
      • Enabling file segmentation

    Edit the relevant settings and click Save.

Use the update REST API method for the ResourceRules resource or the ResourceRulesService/Update gRPC API call.

See alsoSee also

  • Location rules Yandex Cloud CDN
  • Configuring resource caching
  • Configuring request redirection
  • Setting up access via a secure token
  • Updating the basic settings of a resource

Was the article helpful?

Previous
Setting up access via a secure token
Next
Managing additional resource settings
© 2025 Direct Cursus Technology L.L.C.