[Graphic] configure high-performance cache for web content cache in nginx

Source: Internet
Author: User
Tags browser cache

Content caching is one of the most effective ways to significantly improve the performance of web sites. Next we will talk about nginx high-performance cache.

Basic principles of content caching

 

 

Cache GET requests.

Use: browser cache, content delivery network, and/or reverse proxy cache.

 

 

HTTP cache mechanism:

1. The content cache capability claimed by the source server. It mainly controls the http header information.

2. Client cache capability of the request, such as GET request.

 

 

What does nginx cache?

1. The cache does not have the GET and HEAD responses of the Set-Cookie.

2. Define a unique original URL, such as proxy_cache_key.

3. Define the Cache time, such as X-Accel-Expires, Cache-Control, and Expires.

Nginx operations

 

 

Nginx configuration

 

 

Cache process

Nginx can be defined using the proxy_cache_use_stale command in the following cases.

 

 

Not only does it cache HTTP, but it also has other features, such:

1. FastCGI functions are similar to HTTP

2. Memcache searches for memcached server content (must be prefilled)

3. uwsgi and SCGI

How to understand these

 

 

Cache meter

$ Upstrem_cache_status variable values include: MISS, BYPASS, EXPIRED, STALE, UPDATING, REVALDATED, and HIT.

 

 

 

 

Extended status monitoring

Cache content on nginx

 

 

How does it work?

1. nginx uses disk-based persistent cache.

2. Pay attention to the following points:

How is the content stored in the cache?

How is the cache loaded at startup?

Cache expiration pruning

Manual cleanup of cache content

 

 

How is cached content stored?

First, define proxy_cache_path.

Define cache key, proxy_cahce_key

Get the content to the cache, and then check the MD5 value

Verify

 

 

Load cache from disk

 

 

Manage disk cache

 

 

Clear disk content

Control cache

 

 

Delayed cache proxy_cache_min_uses saves disk write

Cache re-verify proxy_cache_revalidate to save upstream bandwidth and disk write

 

 

Cache time control

 

 

 

 

Multiple caches

Why cache

 

 

Increase webpage speed

 

 

 

 

 

 

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.