Nginx setting Browser Local cache

Source: Internet
Author: User

Browser local cache, that is, when the browser loads a Web page, you can cache some of the content of the Web page, the local content will be loaded again, this can greatly improve the speed of access to the site. For the server side, this will also greatly save network resources.

Browser caching relies on the Expires command output header to achieve:

syntax: Expires [Time|epoch|max|off]

Default value: Expires off

Scope: Http,server,location

Use this directive to control the header information of "Expires" and "Cache-contron" in HTTP reply, and play the role of controlling the page cache.

You can use positive and negative numbers in the time value. The value of the "Expires" header is obtained by adding the time value to the current system.

EOPCH specifies a value of "Expires" of 1 january,1970,00:00:01 GMT.

MAX Specifies a value of December 2037 23:59:59 GMT, and the value of "Cache-control" is 10 years. 1 specifies that the value of "Expires" is the -1s of the current time, i.e. never expires.

The value of the "Cache-control" header is determined by the time you specify.

Off means that the values of "Expires" and "Cache-control" are not modified.

example, if you set the website to common format pictures, flash and other files in the browser local cache for 10 days, the JS, CSS and other dynamic files cache for 1 hours, you can modify or add the following configuration in the server module to achieve:

Server

{

Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $

{

Expires 10d;

}

Location ~. *\. (JS|CSS) $

{

Expires 1h;

}

}


Nginx setting Browser Local cache

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.