هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Configuring a Cache Rule

Updated on 2024-05-16 GMT+08:00

Function

This API is used to configure a content cache rule for CDN nodes.

URI

PUT /v1.0/cdn/domains/{domain_id}/cache

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

domain_id

Yes

String

Specifies the acceleration domain name ID. For details, see Querying Details About a Domain Name.

Table 2 Query Parameters

Parameter

Mandatory

Type

Description

enterprise_project_id

No

String

Enterprise project that the domain name to be modified belongs to. This parameter is valid only when the enterprise project function is enabled. The value all indicates all projects. This parameter is mandatory when you use an IAM user to call this API.

Obtain the enterprise project ID by calling the ListEnterpriseProject API of Enterprise Project Management Service (EPS).

Request Parameters

Table 3 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies the user token.

The token can be obtained by calling the IAM API used to obtain a user token. The value of **X-Subject-Token** in the response header is the user token.
Table 4 Request body parameters

Parameter

Mandatory

Type

Description

cache_config

Yes

CacheConfigRequest object

Specifies the cache configuration.

Table 5 CacheConfigRequest

Parameter

Mandatory

Type

Description

ignore_url_parameter

No

Boolean

Specifies whether to ignore URL parameters.

follow_origin

No

Boolean

Specifies whether to enable origin cache control.

compress

No

CompressRequest object

Specifies the gzip compression settings.

rules

No

Array of Rules objects

Specifies the cache rules, which overwrite the previous rule configurations. Blank rules are reset to default rules.

Array Length: 1 - 20

Table 6 CompressRequest

Parameter

Mandatory

Type

Description

compress_switch

No

Integer

Specifies whether gzip compression is enabled. Possible values: 0 (disabled) and 1 (enabled).

Table 7 Rules

Parameter

Mandatory

Type

Description

rule_type

Yes

Integer

0: All types of files are matched. It is the default value. 1: Files are matched based on their suffixes. 2: Files are matched based on their directories. 3: Files are matched based on their full paths.

content

No

String

Specifies the content that matches rule_type. If rule_type is set to 0, this parameter is empty. If rule_type is set to 1, the value of this parameter is a list of file name extensions. A file name extension starts with a period (.). File name extensions are separated by semicolons (;), for example, .jpg;.zip;.exe. If rule_type is set to 2, the value of this parameter is a list of directories. A directory starts with a slash (/). Directories are separated by semicolons (;), for example, /test/folder01;/test/folder02. If rule_type is set to 3, the value of this parameter is a full path. A full path starts with a slash (/). Wildcard characters (*) are supported. For example, /test/index.html and /test/*.jpg.

ttl

Yes

Integer

Specifies the cache age. The maximum cache age is 365 days.

ttl_type

Yes

Integer

Specifies the unit of the cache age. Possible values: 1 (second), 2 (minute), 3 (hour), and 4 (day).

priority

Yes

Integer

Specifies the priority weight of this rule. The default value is 1. A larger value indicates a higher priority. The value ranges from 1 to 100. The weight values must be unique.

Response Parameters

Status code: 200

Table 8 Response body parameters

Parameter

Type

Description

cache_config

CacheConfig object

Specifies the cache configuration.

Table 9 CacheConfig

Parameter

Type

Description

ignore_url_parameter

Boolean

Specifies whether to ignore URL parameters.

follow_origin

Boolean

Specifies whether to enable origin cache control.

compress

CompressResponse object

Specifies the gzip compression settings.

rules

Array of Rules objects

Specifies the cache rules, which overwrite the previous rule configurations. Blank rules are reset to default rules.

Array Length: 1 - 20

Table 10 CompressResponse

Parameter

Type

Description

compress_switch

Integer

Specifies whether gzip compression is enabled. Possible values: 0 (disabled) and 1 (enabled).

compress_rules

Array of CompressRules objects

Specifies the gzip compression rule.

Table 11 CompressRules

Parameter

Type

Description

compress_type

String

Specifies the compression type. Currently, the value can only be set to gzip.

compress_file_type

String

Specifies the file types supported by gzip compression. File types are separated by vertical bars (|), for example, .js|.html|.css|.xml.

Table 12 Rules

Parameter

Type

Description

rule_type

Integer

0: All types of files are matched. It is the default value. 1: Files are matched based on their suffixes. 2: Files are matched based on their directories. 3: Files are matched based on their full paths.

content

String

Specifies the content that matches rule_type. If rule_type is set to 0, this parameter is empty. If rule_type is set to 1, the value of this parameter is a list of file name extensions. A file name extension starts with a period (.). File name extensions are separated by semicolons (;), for example, .jpg;.zip;.exe. If rule_type is set to 2, the value of this parameter is a list of directories. A directory starts with a slash (/). Directories are separated by semicolons (;), for example, /test/folder01;/test/folder02. If rule_type is set to 3, the value of this parameter is a full path. A full path starts with a slash (/). Wildcard characters (*) are supported. For example, /test/index.html and /test/*.jpg.

ttl

Integer

Specifies the cache age. The maximum cache age is 365 days.

ttl_type

Integer

Specifies the unit of the cache age. Possible values: 1 (second), 2 (minute), 3 (hour), and 4 (day).

priority

Integer

Specifies the priority weight of this rule. The default value is 1. A larger value indicates a higher priority. The value ranges from 1 to 100. The weight values must be unique.

Example Requests

PUT https://cdn.myhuaweicloud.com/v1.0/cdn/domains/ff808***********************2d71/cache?enterprise_project_id=0

{
  "cache_config" : {
    "ignore_url_parameter" : false,
    "follow_origin" : false,
    "compress" : {
      "compress_switch" : 1
    },
    "rules" : [ {
      "rule_type" : 1,
      "content" : ".jpg;.png",
      "ttl" : 30,
      "ttl_type" : 3,
      "priority" : 1
    } ]
  }
}

Example Responses

Status code: 200

OK

{
  "cache_config" : {
    "rules" : [ {
      "rule_type" : 1,
      "content" : ".jpg;.png",
      "ttl" : 30,
      "ttl_type" : 3,
      "priority" : 1
    }, {
      "rule_type" : 0,
      "content" : "",
      "ttl" : 600,
      "ttl_type" : 1,
      "priority" : 1
    } ],
    "ignore_url_parameter" : false,
    "follow_origin" : false,
    "compress" : {
      "compress_switch" : 1,
      "compress_rules" : [ {
        "compress_type" : "gzip",
        "compress_file_type" : ".js|.html|.css|.xml|.json|.shtml|.htm"
      } ]
    }
  }
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback