Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx cache priority

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Brothers who come into contact with nginx have more or less encountered cache problems, either why nginx does not cache, or why nginx cache expires quickly, and so on. You can refer to the article on nginx cache priority on the Internet.

Architecture diagram

Client-side nginx cache source server

After a large number of tests, it is found that the expiration order of nginx has a priority. The following first describes the factors that affect cache expiration:

(1) inactive: configure in the proxy_cache_path configuration item to indicate that if a cache is not accessed within the time specified by inactive, it will be deleted from the cache.

(2) the Expires in the response header generated in the php page of the source server, and the generated statement is:

Header ("Expires: Fri, 07 Sep 2013 08:05:18 GMT")

(3) the max-age generated by the php page of the source server. The generation statement is as follows:

Header ("Cache-Control: max-age=60")

(4) configuration item proxy_cache_valid of nginx: configure the cache time of cache files in nginx cache, if the configuration item is: proxy_cache_valid 200 304 2m; it means that the cache time for cache files with status 200and 304 is 2 minutes, and when you access the cache file two minutes later, the file will expire and go to the source server to retrieve data.

Secondly, it explains the conflict between the expires of the source server and the expires configuration item of nginx cache. The scenario is as follows

(1) the php file ta1.php on the source server is as follows:

1 2 3 4 5 6

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report