1.官網
http://nginx.org/en/docs/http/ngx_http_headers_module.html
2.英文
Syntax: expires [modified] time;
expires epoch | max | off;
Default:
expires off;
Context: http, server, location, if in location
Enables or disables adding or modifying the “Expires” and “Cache-Control” response header fields provided that the response code equals 200, 201 (1.3.10), 204, 206, 301, 302, 303, 304, 307 (1.1.16, 1.0.13), or 308 (1.13.0). The parameter can be a positive or negative time.
The time in the “Expires” field is computed as a sum of the current time and time specified in the directive. If the modified parameter is used (0.7.0, 0.6.32) then the time is computed as a sum of the file’s modification time and the time specified in the directive.
In addition, it is possible to specify a time of day using the “@” prefix (0.7.9, 0.6.34):
expires @15h30m;
The contents of the “Cache-Control” field depends on the sign of the specified time:
time is negative — “Cache-Control: no-cache”.
time is positive or zero — “Cache-Control: max-age=t”, where t is a time specified in the directive, in seconds.
The epoch parameter sets “Expires” to the value “Thu, 01 Jan 1970 00:00:01 GMT”, and “Cache-Control” to “no-cache”.
The max parameter sets “Expires” to the value “Thu, 31 Dec 2037 23:55:55 GMT”, and “Cache-Control” to 10 years.
The off parameter disables adding or modifying the “Expires” and “Cache-Control” response header fields.
The last parameter value can contain variables (1.7.9):
map $sent_http_content_type $expires {
default off;
application/pdf 42d;
~image/ max;
}
expires $expires;
2.中文
句法: expires [modified] time;
expires epoch | max | off;
默認:
到期;
內容: http,server,location,if in location
如果響應代碼等於200、201(1.3.10),204、206、301、302、303、304、307(1.1。),則啓用或禁用添加或修改“ Expires”和“ Cache-Control”響應標頭字段。 16、1.0.13)或308(1.13.0)。該參數可以是正或負 時間。
“ Expires”字段中的時間是當前時間的總和,並time在指令中指定。如果使用了modified參數(0.7.0,0.6.32),則該時間將作爲文件的修改時間與time指令中指定的時間之和來計算。
另外,可以使用“ @”前綴(0.7.9,0.6.34)指定一天中的時間:
在15h30m到期;
“ Cache-Control”字段的內容取決於指定時間的符號:
時間爲負數-“緩存控制:無緩存”。
time爲正數或爲零—“ Cache-Control:max-age = t”,其中t是指令中指定的時間,以秒爲單位。
該epoch參數將“ Expires”設置爲值“ Thu, 01 Jan 1970 00:00:01 GMT”,將“ Cache-Control”設置爲“ no-cache”。
該max參數將“ Expires”設置爲值“ Thu, 31 Dec 2037 23:55:55 GMT”,並將“ Cache-Control”設置爲10年。
該off參數禁用添加或修改“ Expires”和“ Cache-Control”響應頭字段。
最後一個參數值可以包含變量(1.7.9):
映射$ sent_http_content_type $ expires {
默認關閉;
申請書/ pdf 42d;
〜image / max;
}
$ expires到期;