> For the complete documentation index, see [llms.txt](https://www.axisnow.io/zh/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.axisnow.io/zh/docs/edge/policies/cache.md).

# 缓存控制

按规则决定边缘是否缓存与缓存多久以及下发给浏览器的缓存指令

缓存控制插件决定每个响应是否在边缘缓存、缓存多久、按什么 Key 区分副本，以及下发给浏览器的缓存指令。边缘缓存命中时请求不再回源，直接由节点应答。

## 位置 <a href="#position" id="position"></a>

缓存控制排在[通用访问控制](/zh/docs/edge/policies/access-control.md)、[速率控制](/zh/docs/edge/policies/rate-limiting.md)等安全插件之后，命中缓存的请求同样经过它们，也计入限速计数；命中缓存的响应仍经过响应控制插件的压缩和响应头改写。

## 规则 <a href="#rules" id="rules"></a>

每条规则给出一组缓存配置，请求取第一条命中规则的配置；没有规则命中的请求不缓存，也不带缓存状态头。

内置一条默认规则排在最后，按 URL 后缀判断、不看响应的 `Content-Type`：后缀属于常见静态资源（图片、脚本、样式、字体、音视频、安装包、文档等）的请求缓存，时长为源站优先、默认 1 小时，默认 Key，分片 5 MB，浏览器缓存遵循源站。HTML、JSON 和没有后缀的接口路径不在其中，需要缓存时自行添加规则。默认规则可以退订。

## 边界 <a href="#boundaries" id="boundaries"></a>

<table data-search="false"><thead><tr><th width="220">功能</th><th>配置位置</th></tr></thead><tbody><tr><td>清理已缓存的内容、预热</td><td><a href="/zh/docs/edge/policies/cache/purge-and-warming.md">缓存清理与预热</a>，策略下的独立入口</td></tr><tr><td>响应压缩、响应头改写</td><td>响应控制插件</td></tr><tr><td>回源地址与回源协议</td><td><a href="/zh/docs/edge/policies/upstream-control.md">回源控制</a>插件</td></tr></tbody></table>

## 下一步 <a href="#next-steps" id="next-steps"></a>

<table data-search="false"><thead><tr><th width="160">页面</th><th>内容</th></tr></thead><tbody><tr><td><a href="/zh/docs/edge/policies/cache/how-it-works.md">工作原理</a></td><td>命中流程、缓存状态的含义、不缓存的响应、节点存储</td></tr><tr><td><a href="/zh/docs/edge/policies/cache/configuration.md">配置项</a></td><td>五个配置项的取值与规则</td></tr><tr><td><a href="/zh/docs/edge/policies/cache/use-cases.md">配置场景</a></td><td>可直接套用的规则</td></tr><tr><td><a href="/zh/docs/edge/policies/cache/purge-and-warming.md">缓存清理与预热</a></td><td>清理的匹配方式与生效时间、预热的执行方式</td></tr><tr><td><a href="/zh/docs/edge/policies/cache/insight.md">洞察与日志</a></td><td>命中率的口径、清理与预热的任务记录</td></tr><tr><td><a href="/zh/docs/edge/policies/cache/faq.md">常见问题</a></td><td>未命中、清理不生效、命中率低的排查</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.axisnow.io/zh/docs/edge/policies/cache.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
