Nginx+proxy_cache Picture Cache

Source: Internet
Author: User

The principle of building image caching mechanism is to reduce the burden of database and speed up the response of static resources.

Steps:

1.vim /usr/local/nginx/conf/nginx.conf

2.

http{      ...      ...      #设置Web缓存区名称为cache_one,内存缓存空间大小为200MB,1天没有被访问的内容自动清除,硬盘缓存空间 大小为30GB      proxy_cache_path  /var/imgcachetest levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g; }Where/var/imgcachetest is the mkdir image cache directory. 3. server{      ...           location / {          proxy_cache cache_one;          proxy_cache_valid  200 304 12h;          #以域名、URI、参数组合成Web缓存的Key值,Nginx根据Key值哈希,存储缓存内容到二级缓存目录内           proxy_cache_key $host$uri$is_args$args;          proxy_set_header Host  $host;          proxy_set_header X-Forwarded-For  $remote_addr;          proxy_pass http: //127 .0.0.1:9000;          expires      1d;      }e }4. When you access the test picture, a picture cache is generated in the/var/imgcachetest directory, complete.

Nginx+proxy_cache Picture Cache

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.