第一步:进入 Edge Rules
第二步:新建规则(核心)
| 配置项 | 填写值 |
|---|---|
| Description(描述) | Bypass cache for index.php(随意) |
| Action(动作) | Override Cache Time |
| Cache time in seconds | 0(为 0 即绕过边缘缓存) |
| Condition(条件) | 点 Add Condition → 选 Request URL,匹配方式选 Match Any |
| 触发值(Trigger) | *index.php*(星号是通配符,能同时命中 /index.php?m=api&c=Ajax&a=get_token 这类带参数的 URL) |
点 Save Edge Rule 保存,规则立即生效,无需等待。
第三步:再加一条浏览器缓存规则(建议)
同样方法再建一条:Action 选 Override Browser Cache Time,值也设 0,条件同样是 Request URL 匹配 *index.php*。防止浏览器本地缓存动态响应。
第四步:配套检查(很重要)
| 位置 | 检查项 |
|---|---|
| Caching → General | Strip Response Cookies 必须关闭(OFF),否则 CDN 会剥离 Set-Cookie,会员登录等功能会异常 |
| Caching → General | Query String Sort / Ignore Query Strings:确保未开启“忽略查询参数”,否则不同接口会被当成同一个 URL 缓存 |
| Caching → Perma-Cache | 如果开启了 Perma-Cache,需要再加一条 Action 为 Bypass Perma-Cache 的规则,条件同样匹配 *index.php* |
第五步:验证是否生效
用命令行或浏览器 F12 查看响应头:
curl -I "https://你的域名/index.php?m=api&c=Ajax&a=get_token&name=__token__test"
规则顺序提醒:Edge Rules 按列表顺序执行,如果你还有其他“延长缓存时间”类规则(如对 html 设长缓存),请把本条 index.php 绕过规则拖到它们上面,避免被覆盖。