日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Nginx >内容正文

Nginx

Nginx:作为缓存,支持Range回源

發布時間:2024/2/28 Nginx 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Nginx:作为缓存,支持Range回源 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、Range回源

1.1 Nginx的Range回源、ngx_http_slice_module模塊、--with-http_slice_module參數

? ? ? ? Nginx的ngx_http_slice_module模塊是用來支持Range回源的。

? ? ? ? ngx_http_slice_module從Nginx的1.9.8版本開始有的。

? ? ? ??啟用ngx_http_slice_module模塊需要在編譯Nginx時,加參數--with-http_slice_module。

1.2 curl指定Range范圍

? ? ? ??-r 指定Range的范圍

1.3 HTTP 206

? ? ? ??HTTP的Range請求,成功返回時的狀態碼是206。

1.4 架構

? ? ? ??緩存、源站

? ? ? ??用戶向緩存請求URL,緩存進行Range回源。

二、緩存配置文件

[plain]?view plaincopy
  • #user??nobody;??
  • worker_processes??1;??
  • ??
  • events?{??
  • ????worker_connections??1024;??
  • }??
  • ??
  • ??
  • http?{??
  • ????log_format??main??'$remote_addr?-?$remote_user?[$time_local]?"$request"?'??
  • ??????????????????????'$status?$body_bytes_sent?"$http_referer"?'??
  • ??????????????????????'"$http_user_agent"?"$http_x_forwarded_for"';??
  • ??
  • ????access_log??logs/access.log??main;??
  • ??
  • ????sendfile????????on;??
  • ??
  • ????keepalive_timeout??65;??
  • ??
  • ????#cache??
  • ????proxy_cache_path?/data/cache??
  • ????????????????keys_zone=cache_my:100m??
  • ????????????????levels=1:1??
  • ????????????????inactive=12d??
  • ????????????????max_size=200m;??
  • ??
  • ????server?{??
  • ????????listen???????80;??
  • ????????server_name??localhost;??
  • ??
  • ????????location?/?{??
  • ????????????????#slice??
  • ????????????????slice?1k;??
  • ????????????????proxy_cache?cache_my;??
  • ????????????????proxy_cache_key?$uri$is_args$args$slice_range;??
  • ????????????????add_header?X-Cache-Status?$upstream_cache_status;??
  • ????????????????proxy_set_header?Range?$slice_range;??
  • ????????????????proxy_cache_valid?200?206?3h;??
  • ????????????????proxy_pass?http://192.168.175.135:80;??
  • ??
  • ????????????????proxy_cache_purge?PURGE?from?127.0.0.1;??
  • ????????}??
  • ????}??
  • }??
  • 三、運行結果

    查看的是源站的日志

    index.html文件大小為5196


    curl www.guowenyan.cn/index.html -r 0-1024


    curl www.guowenyan.cn/index.html



    參考資料:

    ? ? ? ??官網ngx_http_slice_module:http://nginx.org/en/docs/http/ngx_http_slice_module.html

    總結

    以上是生活随笔為你收集整理的Nginx:作为缓存,支持Range回源的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。