Prerequisite: You need to compile the ngx_http_headers_module module to support header information operations add_header It means to add custom header information to the response header. The instruction is add_header name value [always];. It can be used in http {}, server {}, location {}, if in location {} context. Note: You can declare multiple add_header instructions. If and only if the current block does not have add_header, the add_header information declared by the parent will be inherited. For example: server { add_header a 123; location / { root /path; } location /download/ { add_header b 321; } } In the example above, when accessing the /download/ route, a header such as b 321 will be returned, while when accessing the / route, a header such as a 123 will be returned as specified by the parent. add_trailer It means to add custom header information to the end of the response header. The instruction is add_trailer name value [always];. It can be used in the http {}, server {}, location {}, if in location {} context. It will only take effect when the response status code is equal to 200, 201, 206, 301, 302, 303, 307, or 308. If the always parameter is specified, the header information will be ignored in all responses. Note: You can declare multiple add_trailer instructions. If and only if there is no add_trailer in the current block, the add_trailer information declared by the parent will be inherited. See add_header for an example. expires Enable or disable, add or modify the "Expires" and "Cache-Control" fields in the response headers. The directives are expires [modified] time; or expires epoch | max | off; which takes effect when the response status code is 200, 201 (1.3.10), 204, 206, 301, 302, 303, 304, 307 (1.1.16, 1.0.13), or 308 (1.13.0). The time parameter can be a positive or negative time. The time in the "Expires" field is calculated as the sum of the current time and the time specified in time. If the modified parameter is used (0.7.0, 0.6.32), the time is calculated as the sum of the file modification time and the time specified in the time directive. Additionally, a time of day can be specified using the "@" prefix (0.7.9, 0.6.34): expires @15h30m; The content of the "Cache-Control" field depends on the symbol at the specified time:
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 argument value can contain variables (1.7.9): For example: map $sent_http_content_type $expires { default off; application/pdf 42d; ~image/ max; } expires $expires; The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed explanation of JavaScript progress management
>>: MySQL 5.7.21 decompression version installation Navicat database operation tool installation
Table of contents 1. Parent component passes valu...
I upgraded my Raspberry Pi server to Ubuntu 20 tw...
Table of contents 1. What is an event? 2. How to ...
In the past, I only knew how to use the name attri...
Maybe you are using include files here, which is u...
Table of contents JSX environment construction In...
This article uses examples to describe MySQL'...
Recently, I need to frequently use iframe to draw ...
Detailed example of getting the maximum value of ...
Problem Description I created three virtual machi...
MySQL temporary tables are very useful when we ne...
Table of contents ESLint plugin installation in H...
IMG tag basic analysis In HTML5, the img tag has ...
Preface When using Docker in a production environ...
Sometimes the input box is small, and you want to...