Home > Backend Development > PHP Tutorial > Nginx browser local cache settings

Nginx browser local cache settings

WBOY
Release: 2016-07-28 08:28:21
Original
1359 people have browsed it

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>
Copy after login
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template