What does `expires -1` mean in NGINX `location` di

2019-02-22 00:11发布

Given the sample location example below, what does -1 mean for expires? Does that mean "never expires" or "never caches"?

# cache.appcache, your document html and data
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
  expires -1;
  access_log logs/static.log;
}

https://github.com/h5bp/server-configs-nginx/blob/master/h5bp/location/expires.conf

2条回答
看我几分像从前
2楼-- · 2019-02-22 00:52

If expires -1 is used, it means that these pages are never cached. The expire directive instructs the browser to expire file cache after a certain amount of time (or at a certain time). If a negative value is given, there is no caching.

查看更多
看我几分像从前
3楼-- · 2019-02-22 01:02

According to nginx manual, this directive adds the Expires and Cache-Control HTTP header to the response.

Value -1 means these headers are set as:

Expires: current time minus 1 second

Cache-Control: no-cache

So in summary it instructs the browser not to cache the document.

查看更多
登录 后发表回答