Traffic Server中的cache.config的字段理解

cache.cofnig 用于配置Traffic Server如何来缓存web对象。你可以像下面这样添加 缓存规则:

  • 从指定IP过来的请求一律不缓存

  • 指定对象保存多久

  • 对象多长时间过期

  • 是否忽略源站的no-cache指令

cache.config 文件的每一行包含一条缓存规则,Traffic Server识别的格式为 空格分割的三个标签:

你可以在一个规则中使用多个二级标识符,但是不能重复使用,下面的列表是所有一级 标识符和可选的值。

  • dest_domain

  • A requested domain name. Traffic Server matches the domain name of the destination from the URL in the request.

    请求域名,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


你可能感兴趣的:(Traffic Server中的cache.config的字段理解)