ATS中cache.config基本配置示例

建站交流5年前 (2020-11-20)8150

1、强制缓存:对www.baidu.com域名下的所有内容都强制缓存60分钟


url_regex=http://www\.baidu\.com.*$ scheme=http ttl-in-cache=60m

dest_domain=www.baidu.com scheme=http ttl-in-cache=60m



nginx配置

    location / {

      root  html;

      index  index.html index.htm;

   expires 30s;

    }


2、www.swm.com下的所有内容强制不缓存

dest_domain=www.swm.com scheme=http action=never-cache



3、www.swm.com下的jpg、gif文件强制不缓存

错误示例:

dest_domain=www.swm.com suffix=jpg suffix=gif scheme=http action=never-cache


正确示例:

dest_domain=www.swm.com suffix=jpg scheme=http action=never-cache

dest_domain=www.swm.com suffix=gif scheme=http action=never-cache


4、www.swm.com下GET方法的jpg、gif文件强制不缓存

dest_domain=www.swm.com suffix=jpg method=GET scheme=http action=never-cache

dest_domain=www.swm.com suffix=gif method=GET scheme=http action=never-cache


5、www.swm.com/docs开始所有内容强制不缓存

url_regex=http://www.swm.com/docs.*$ scheme=http action=never-cache


6、正则方式,www.swm.com下的txt文件强制不缓存

url_regex=http://www.swm.com.*\.txt$ scheme=http action=never-cache


nginx配置

    location / {

      root  html;

      index  index.html index.htm;

   add_header Cache-Control no-store;

    }


7、www.swm.com下的所有内容强制缓存2小时

dest_domain=www.swm.com scheme=http ttl-in-cache=2h


8、www.swm.com下的后缀为jpg和gif的文件强制缓存2小时

dest_domain=www.swm.com suffix=jpg scheme=http ttl-in-cache=2h

dest_domain=www.swm.com suffix=gif scheme=http ttl-in-cache=2h


9、www.swm.com下GET方法的后缀为jpg和gif的文件强制缓存2小时

dest_domain=www.swm.com suffix=jpg method=GET scheme=http ttl-in-cache=2h

dest_domain=www.swm.com suffix=gif method=GET scheme=http ttl-in-cache=2h


10、www.swm.com/docs开始所有内容强制缓存2小时

url_regex=http://www.swm.com/docs.*$ scheme=http ttl-in-cache=2h


11、正则方式,www.swm.com下的txt文件强制缓存2小时

url_regex=http://www.swm.com.*\.txt$ scheme=http ttl-in-cache=2h


nginx配置

    location / {

      root  html;

      index  index.html index.htm;

   expires 30s;

    }


12、www.swm.com下的所有内容强制有效2分钟 

dest_domain=www.swm.com scheme=http revalidate=2m


13、www.swm.com下的后缀为jpg和gif的文件强制有效2分钟

dest_domain=www.swm.com suffix=jpg scheme=http revalidate=2m

dest_domain=www.swm.com suffix=gif scheme=http revalidate=2m


14、www.swm.com下GET方法的后缀为jpg和gif的文件强制有效2分钟

dest_domain=www.swm.com suffix=jpg method=GET scheme=http revalidate=2m

dest_domain=www.swm.com suffix=gif method=GET scheme=http revalidate=2m


15、www.swm.com/docs开始所有内容强制有效2分钟

url_regex=http://www.swm.com/docs.*$ scheme=http revalidate=2m


16、正则方式,www.swm.com下的txt文件强制有效2分钟

url_regex=http://www.swm.com.*\.txt$ scheme=http  revalidate=2m



17、除www.swm.com的jpg\gif缓存2小时,其它不缓存

dest_domain=www.swm.com suffix=jpg scheme=http ttl-in-cache=2h

dest_domain=www.swm.com suffix=gif scheme=http ttl-in-cache=2h

dest_domain=www.swm.com scheme=http action=never-cache


或者

dest_domain=www.swm.com scheme=http action=never-cache

dest_domain=www.swm.com suffix=jpg scheme=http ttl-in-cache=2h

dest_domain=www.swm.com suffix=gif scheme=http ttl-in-cache=2h


或者

url_regex=http://www\.swm\.com/.*$ action=never-cache

url_regex=http://www\.swm\.com/.*\.(jpg|gif)$ ttl-in-cache=2h


或者

url_regex=http://www\.swm\.com/.*\.(jpg|gif)$ ttl-in-cache=2h

url_regex=http://www\.swm\.com/.*$ action=never-cache



18、www.swm.com的jpg\gif缓存2小时,其它缓存10分钟

dest_domain=www.swm.com suffix=jpg scheme=http ttl-in-cache=2h

dest_domain=www.swm.com suffix=gif scheme=http ttl-in-cache=2h

dest_domain=www.swm.com scheme=http ttl-in-cache=10m


或者

url_regex=http://www\.swm\.com/.*\.(jpg|gif)$ ttl-in-cache=2h

url_regex=http://www\.swm\.com/.*$ ttl-in-cache=10m


或者

dest_domain=www.swm.com suffix=jpg method=GET scheme=http ttl-in-cache=2h

dest_domain=www.swm.com suffix=gif method=GET scheme=http ttl-in-cache=2h

url_regex=http://www\.swm\.com/.*$ ttl-in-cache=10m


错误示例(所有内容只缓存了10分钟):

dest_domain=www.swm.com scheme=http ttl-in-cache=10m

dest_domain=www.swm.com suffix=jpg scheme=http ttl-in-cache=2h

dest_domain=www.swm.com suffix=gif scheme=http ttl-in-cache=2h


或者

url_regex=http://www\.swm\.com/.*$ ttl-in-cache=10m

url_regex=http://www\.swm\.com/.*\.(jpg|gif)$ ttl-in-cache=2h


或者

url_regex=http://www\.swm\.com/.*$ ttl-in-cache=10m

dest_domain=www.swm.com suffix=jpg method=GET scheme=http ttl-in-cache=2h

dest_domain=www.swm.com suffix=gif method=GET scheme=http ttl-in-cache=2h



19、www.swm.com下的所有内容都不缓存

url_regex=http://www\.swm\.com/.*$ action=never-cache

dest_domain=www.swm.com suffix=jpg method=GET scheme=http ttl-in-cache=2h

dest_domain=www.swm.com suffix=gif method=GET scheme=http ttl-in-cache=2h


20、www.swm.com的jpg\gif缓存2小时,其它不缓存

dest_domain=www.swm.com suffix=jpg method=GET scheme=http ttl-in-cache=2h

dest_domain=www.swm.com suffix=gif method=GET scheme=http ttl-in-cache=2h

url_regex=http://www\.swm\.com/.*$ action=never-cache


标签: ATS缓存cdn

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。