cache.cofnig 用於配置Traffic Server如何來緩存web對象。你能夠像下面這樣添加 緩存規則:html
從指定IP過來的請求一概不緩存web
指定對象保存多久express
對象多長時間過時緩存
是否忽略源站的no-cache指令dom
cache.config 文件的每一行包含一條緩存規則,Traffic Server識別的格式爲 空格分割的三個標籤:post
你能夠在一個規則中使用多個二級標識符,可是不能重複使用,下面的列表是全部一級 標識符和可選的值。url
dest_domainserver
A requested domain name. Traffic Server matches the domain name of the destination from the URL in the request.htm
請求域名,Traffic Server匹配請求URL中的的域名。對象
dest_host
A requested hostname. Traffic Server matches the hostname of the destination from the URL in the request.
請求主機名。Traffic Server匹配請求URL中的主機名。
dest_ip
A requested IP address. Traffic Server matches the IP address of the destination in the request.
請求IP地址。Traffic Server匹配請求中的目的IP地址。
url_regex
A regular expression (regex) to be found in a URL.
正則匹配請求URL
在 cache.config 二級標識符是可選的。下面是全部二級標識符和可選的值。
port
A requested URL port.
請求URL中的端口號
scheme
A request URL protocol: http or https.
請求URL的協議:http或者https
prefix
A prefix in the path part of a URL.
URL前綴
suffix
A file suffix in the URL.
URL後綴
method
A request URL method: get, put, post, trace.
請求URL的方法:get, put, post, trace
time
A time range, such as 08:00-14:00.
時間範圍,好比8:00-14:00
src_ip
A client IP address.
客戶端IP地址
The following list shows possible actions and their allowed values.
下邊列表列出了全部規則和對應的值。
action
One of the following values:
可選的值以下:
never-cache 永遠不存
ignore-no-cache 忽略全部 Cache-Control: nocache 的報頭
ignore-client-no-cache 忽略客戶端的 nocahe 報頭
ignore-server-no-cache 忽略服務端的 nocache 報頭
cluster-cache-local 容許集羣在每一個節點緩存內容
pin-in-cache
在緩存中保持資源的時間,有如下幾種表示格式:
d 天
h 時
m 分
s 秒
mixed 混合
d for days; for example: 2d
h for hours; for example: 10h
m for minutes; for example: 5m
s for seconds; for example: 20s
mixed units; for example: 1h15m20s
revalidate
資源在緩存中的壽命。格式和 pin-in-cache 一致
ttl-in-cache
無論Cache-Control是什麼樣的,該配置控制對象保存時間,格式與 pin-in-cache同樣
Cache.config中每一行是一條緩存規則,其中包含三種標籤,其中第二個種標籤能夠配置多
個其他的只容許配置一個。
就我配置一個客戶做爲例子吧:
這個URL不緩存:www.978cd.com下的.*device\/register.*規則不緩存 全站每6小時更新緩存一次
url_regex=http://www\.978cd\.com/.*device\/registe.*$ scheme=http action=never-cache
url_regex=https://www\.978cd\.com/.*device\/registe.*$ scheme=https action=never-cache
url_regex=http://www\.978cd\.com/.*$ scheme=http revalidate=6h
url_regex=https://www\.978cd\.com/.*$ scheme=https revalidate=6h
而下面的配置方式是錯誤的:
url_regex=http://www\.978cd\.com/.*device\/registe.*$ scheme=http action=never-cache revalidate=6h
url_regex=https://www\.978cd\.com/.*device\/registe.*$ scheme=https action=never-cache revalidate=6h