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, the memory cache space size is 200mb,1 days without access to the content is automatically cleared, the hard disk cache space size is 30GB Proxy_cache_path/var/imgcache Test 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 304 12h;        #以域名, URI, parameters combined into the Web cache key value, Nginx based on the key value hash, storage cache content to the level two cache directory 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:8080;    Expires 1d; }e}

4. When you access the test picture, a picture cache is generated in the/var/imgcachetest directory, complete.

This article from "The day will be down to the great people also" blog, please be sure to keep this source http://19940428.blog.51cto.com/13352428/1972152

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.