NGINX 的 location 指令中的 expires -1 是什么意思?

What does `expires -1` mean in NGINX `location` directive?

给定下面的示例 location-1expires 意味着什么?这是否意味着“永不过期”或“永不缓存”?

# 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/b935688c2b/h5bp/location/expires.conf

如果使用expires -1,则意味着这些页面永远不会被缓存。 expire 指令指示浏览器在一定时间后(或在特定时间)使文件缓存过期。如果给定一个负值,则没有缓存。

根据 nginx manual,此指令将 ExpiresCache-Control HTTP header 添加到响应中。

-1表示这些header被设置为:

Expires: current time minus 1 second

Cache-Control: no-cache

总之,它指示浏览器不要缓存文档。