Linux Nginx set Proxy_cache cache and cancel cache

Source: Internet
Author: User

Within the server{} of the configuration file, add one sentence:

The code is as follows Copy Code

Location ~. * * *. (CSS|JS) $ {
Add_header Cache-control ' No-store ';
}


Add the following code to the HTTP block in the nginx.conf

#proxy_temp_path和proxy_cache_path指定的路径必须在同一分区
Proxy_temp_path/tmp/proxy_temp_dir;
#设置名称为nginx_cache, the memory cache space size is 500mb,30 Day has not been accessed automatically clear, hard disk cache space size of 30GB.
Proxy_cache_path/tmp/proxy_cache_dir levels=1:2 keys_zone=nginx_cache:200m inactive=3d max_size=30g;


Add the following code to the server

The code is as follows Copy Code

Location/{
Proxy_cache Nginx_cache;
Proxy_cache_key $host $uri$is_args$args;
Proxy_set_header Host $host;
Proxy_set_header x-forwarded-for $remote _addr;
Expires 30d;
}

Restart Ngnix

  code is as follows copy code

/usr/local /nginx/sbin/nginx-s Reload

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.