Nginx cache expiration Management Summary

Source: Internet
Author: User

Nginx cache expiration Management Summary let's look at a classic configuration: proxy_cache_path/cache levels = keys_zone = cache_pool: 512 minactive = 1 m max_size = 10g; location ~. *\. (Jpg | gif | png) $ {response http_502 http_504 error timeout invalid_header; proxy_cache cache_pool; Response 200 304 2 m; Response $ host $ uri $ is_args $ args; proxy_set_header Host $ host; proxy_set_header X-Forwarded-For $ remote_addr; proxy_pass http: // storage1; expires 10 m;} someone on the Forum asked me what the meaning of these three times really mean, what are their functions? First read the explanation on the official website: Cached data that are not accessed during the time specified by the inactive parameter get removed from the cache regardless of their freshness. by default, inactive is set to 10 minutes. (If the cached data is not accessed within the time specified by the inactive parameter, it will be removed from the cache, whether or not it is just generated. The default value of inactive is 10 minutes.) Sets caching time for different response codes. for example, the following directivesproxy_cache_valid 200 302 10 m; proxy_cache_valid 404 1 m; set 10 minutes of caching for responses with codes 200 and 302, and 1 minute for responses with code 404. expires: Controls whether the response shoshould be marked with an expiry time, and if so, what time that is. here, the inactive time indicates the specified time of a file. Is removed from the storage system, regardless of the time you set in proxy_cache_valid. Proxy_cache_valid ensures the maximum available time when it is accessed within the inactive period. Proxy_cache_valid defines an absolute expiration time (the first Cache Time + the configured Cache Time). At this point, the object is considered to have expired and then the data is retrieved from the backend, although it is frequently accessed (the so-called inactive time ). Expires is not in this expiration control system. It is used in the response sent to the client to add the "Expires" header.

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.