Nginx sets local browser cache file

Source: Internet
Author: User

Browser cache is used to accelerate browsing and save network resources. The browser stores recently requested documents on the user's disk.

Nginx can use the expires command to set the browser header.

Syntax: expires [time | epoch | max | Off]

Default Value: expires off

Scope: HTTP, server, location

This command can be used to control the header labels of "expires" and "cache-control" in the HTTP Response (to control the page cache ).

You can use a positive or negative number in the time value. The value of the "expires" header is obtained by the current system time plus the time value you set.

Epoch specifies that the value of "expires" is 1 January, 1970, 00:00:01 GMT.

Max specifies that the value of "expires" is 31 December 2037 23:59:59 GMT, and the value of "cache-control" is 10 years.

-1 specify the value of "expires" as the current server time-1 s, that is, permanently expired

Example:

Image cache for 30 days

Location ~. * \. (JPG | PNG | JPEG) $
{
Expires 30d;
}

Javascript CSS cache for one hour
Location ~. * \. (JS | CSS )? $
{
Expires 1 h;
}

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.