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)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM