Nginx expires cache boosts Web site load

Source: Internet
Author: User

Syntax: Expires [Time|epoch|max|off]
Default value: Expires off
Scope: HTTP, server, location
Use this directive to control the headers of "Expires" and "Cache-control" in HTTP replies (as a function of controlling page caching).
You can use a positive or negative number in the time value. The value of the "Expires" header is obtained by adding the time value you set for the current system.
The epoch specifies a value of "Expires" of 1 January, 1970, 00:00:01 GMT.
MAX specifies that the value of "Expires" is December 2037 23:59:59 GMT, and the value of "Cache-control" is 10 years.
1 specifies that the value of "Expires" is -1s the current time of the server, i.e. forever expires
The value of the "Cache-control" header is determined by the time you specify:
Negative Number: Cache-control:no-cache
Positive or 0: Cache-control:max-age = #, # Specifies the number of seconds for your time.
"Off" means that the values of "Expires" and "Cache-control" are not modified
Demo
Control pictures and other expiration time is 30 days, of course, this time can be set longer. Depending on the situation
Like what
location~ \. (Gif|jpg|jpeg|png|bmp|ico) $ {
Expires 30d;
}
Control all file cache settings to match/resource/or/mediatormodule/to maximum time
Like what

Location ~/(Resource|mediatormodule)/{
Root/opt/demo;
Expires Max;
}

Nginx expires cache boosts Web site load

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.