Browser caching can be implemented by outputting the Header header through the expires directive. The syntax of the expires directive is as follows:
Grammar: expires [time|epoch|max|off]
Default value: expires off
Scope: http, server, location
Purpose: Use this command to control the header information of "Expires" and "Cache-Control" in the HTTP response (to control page caching).
You can use positive or negative numbers in the time value. The value of the "Expires" header will be obtained by adding the current system time to the time value you set.
The value of the "Cache-Control" header is determined by the time you specify.
Negative number: Cache-Control: no-cache
Positive number or zero: Cache-Control:max-age=#
(#The number of seconds you specify the time)
"off" means not to modify the values of "Expires" and "Cache-Control".
Example: Common images and Flash files are cached locally in the browser for 30 days, and js and css files are cached locally in the browser for 1 hour.
The code is as follows:
<code>location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)<span>$ </span>{ expires <span>30</span>d; } location ~ .*\.(js|css)?<span>$ </span>{ expires <span>1</span>h; }</code>
The above introduces the browser local cache settings of Nginx, including relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.