# 添加缓存规则

Time-to-live (TTL) 指的是对象在 Zenlayer 内容分发网络（CDN）节点中缓存的时间。当 TTL 过期后，试图访问已过期内容的请求将被重定向到源站。您可以基于文件目录或文件扩展名添加静态内容的缓存规则。

## 操作步骤

1. 在域名列表中点击一个域名。
2. 转到 **缓存配置** > **添加策略** 以添加缓存过期策略。
3. 启用/禁用 **忽略缓存**（无参数缓存）。

<div align="left"><figure><img src="/files/bLO8WEcjYS5KMmVNxOjo" alt="" width="375"><figcaption><p>添加缓存规则</p></figcaption></figure></div>

| 参数   | 描述                                                                                                                                                                       |
| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 类型   | <p>选择目录、文件扩展名或全站。<br>目录：为特定目录中的资源添加缓存规则。<br>文件扩展名：为具有相同文件名后缀的文件添加缓存规则。<br>全站：为整个站点设置默认缓存规则。</p>                                                                          |
| 过期时间 | <p>指定 TTL。最大 TTL 为一年。参考以下规则：<br>对于静态文件，如图片和应用程序包，通常建议 TTL 为一个月或更长。<br>对于经常更新的静态文件，如 JavaScript 和 CSS 文件，通常建议 TTL 为 7 天。<br>对于动态文件，如 PHP、JSP 和 ASP 文件，通常建议 TTL 为 0 秒。</p> |
| 权重范围 | <p>指定缓存规则的权重。<br>权重表示缓存规则的优先级。有效值范围：1 到 999。值越大，优先级越高。</p>                                                                                                               |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.console.zenlayer.com/welcome/cn/content-delivery-network/domain-management/add-a-cache-rule.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
