ATS+NIGNX 验证缓存(二) --配置源站nginx 缓存时间

打开 nginx 配置文件: vim nginx.conf,编辑:

http {
    include       mime.types;
    default_type  application/octet-stream;
    add_header    Cache-Control max-age=300;                                                  //添加这样的代码
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

保存后退出!然后验证

[root@nginx sbin]# ./nginx -t                                                                        //检查配置文件, -t   : test configuration and exit
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

测试验证,成功!

[root@nginx sbin]# curl -I "http://192.168.202.130/icon.png"
HTTP/1.1 200 OK
Server: nginx/1.10.1
Date: Mon, 25 Jul 2016 11:02:34 GMT
Content-Type: image/png
Content-Length: 8133
Last-Modified: Fri, 15 Jul 2016 09:01:24 GMT
Connection: keep-alive
ETag: "5788a664-1fc5"
Cache-Control: max-age=300                                                                      // nginx设置的header: cache-control 生效!
Accept-Ranges: bytes

然后验证缓存服务器ATS的Cache-Control信息:

[root@nginx ~]# curl -I "HTTP://192.268.202.129/icon.png"
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 25 Jul 2016 04:35:08 GMT
Content-Type: text/html
Content-Length: 164
Last-Modified: Wed, 25 Mar 2015 09:33:00 GMT
Connection: close
Accept-Ranges: bytes

通过ATS服务器进行从NGINX下载测试文件发现并没有Cache-Control头信息

[root@nginx ~]# curl -I "http://192.168.202.129/icon.png"
HTTP/1.1 200 OK
Server: ATS/6.1.1
Date: Mon, 25 Jul 2016 15:24:48 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Thu, 21 Jul 2016 18:01:48 GMT
ETag: "57910e0c-264"
Accept-Ranges: bytes
Age: 6710
Connection: keep-alive
Via: http/1.1 bi (ApacheTrafficServer/6.1.1)

 

转载于:https://www.cnblogs.com/persistcat/p/5702802.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值