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

mac2022-06-30  110

打开 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 exitnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: 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 OKServer: nginx/1.10.1Date: Mon, 25 Jul 2016 11:02:34 GMTContent-Type: image/pngContent-Length: 8133Last-Modified: Fri, 15 Jul 2016 09:01:24 GMTConnection: keep-aliveETag: "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 OKServer: nginxDate: Mon, 25 Jul 2016 04:35:08 GMTContent-Type: text/htmlContent-Length: 164Last-Modified: Wed, 25 Mar 2015 09:33:00 GMTConnection: closeAccept-Ranges: bytes

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

[root@nginx ~]# curl -I "http://192.168.202.129/icon.png"HTTP/1.1 200 OKServer: ATS/6.1.1Date: Mon, 25 Jul 2016 15:24:48 GMTContent-Type: text/htmlContent-Length: 612Last-Modified: Thu, 21 Jul 2016 18:01:48 GMTETag: "57910e0c-264"Accept-Ranges: bytesAge: 6710Connection: keep-aliveVia: http/1.1 bi (ApacheTrafficServer/6.1.1)

 

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

相关资源:JAVA上百实例源码以及开源项目
最新回复(0)