nginx 缓存时间说明

nginx 缓存时间说明

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.

(被缓存的数据如果在inactive参数指定的时间内未被访问,就会被从缓存中移除,不论它是否是刚产生的。inactive的默认值是10分钟)

Sets caching time for different response codes. For example, the following directives

proxy_cache_valid 200 302 10m;

proxy_cache_valid 404 1m;

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 should be marked with an expiry time, and if so, what time that is.

这里总结下:

inactive的时间表示一个文件在指定时间内没有被访问过,就从存储系统中移除,不管你proxy_cache_valid里设置的时间是多少。而proxy_cache_valid在保证inactive时间内被访问过的前提下,最长的可用时间。proxy_cache_valid定义的其实是一个绝对过期时间(第一次缓存的时间+配置的缓存时间),到了这个点,对象就被认为是过期,然后去后端重取数据,尽管它被访问的很频繁(即所谓的inactive时间内)。expires呢,它不在这个过期控制体系内,它用在发给客户端的响应中,添加"Expires"头。关于expires指令的具体用法,可以参考官方wiki。

免责声明:本网信息来自于互联网,目的在于传递更多信息,并不代表本网赞同其观点。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,并请自行核实相关内容。本站不承担此类作品侵权行为的直接责任及连带责任。如若本网有任何内容侵犯您的权益,请及时联系我们,本站将会在24小时内处理完毕。
相关文章
返回顶部