Use Nginx as the Web cache, located between the content source Web server and the client.
Solution for Web caching:
1 Squid Cache
2 Nginx Proxy_cache.
Let's see, Nginx's Proxy_cache.
Composition: Proxy_cache related instruction set, fastcgi related instruction set
Proxy_cache which buffer will be used
Proxy_cache_path Cache file Storage Path
Proxy_cache_methods which HTTP methods are cached
Minimum number of Proxy_cache_min_users cache usage
Proxy_cache_valid sets different cache times for URLs with different return status codes
Proxy_cache_key sets cache key value, Nginx hash cache based on key value
Install a third party Ngx_cache_purge module:
Deletes the specified URL cache
Nginx Web Caching Service
Step One:
Ulimit-shn 65535
Install Pcre./configure && make && make install
Install Ngx_cache_purge as long as the decompression is OK
Installation
code example:
Nginx./configure--user=www--group=www--add-module=. /ngx_cache_purge
--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_model
&& make && make install
Step Two:
Create 2 Cache Directories
code example:
Mkdir-p/data0/proxy_temp_path
Mkdir-p/data0/proxy_cache_path
Step Three:
Configuring the nginx.conf Cache
code example:
http{
...
Proxy_temp_path ...;
Proxy_cache_path ...;
server{
...
Proxy_cache Cache_name;
Proxy_cache_valid ...;
Proxy_cache_key ...;
}
}
For the Nginx cache configuration, here are several articles recommended, you can also refer to the following:
Nginx Cache Configuration Instance
Nginx set the static file cache time
Nginx cache local static files
Nginx Five kinds of caching methods
Nginx methods for caching static files
Nginx Proxy_cache Cache Configuration
Nginx front-end proxy, caching
Next, 谫, fastcgi cache configuration.
Parameter description:
Which buffer is used by the Fastcgi_cache cache
Fastcgi_cache_path set the path to store cached files
Fastcgi_cache_methodes sets which HTTP methods are cached, the default HTTP Get/head method
Fastcgi_cache_min_users sets the minimum number of times to use the cache, default 1
Fastcgi_cache_valid sets different cache times for URLs that return different status codes
Fastcgi_cache_key sets the key value of the Web cache, Nginx the hash storage cache based on the key value MD5
Step One:
Create cache directory: Cache path must be on the same disk partition
code example:
Mkdir-p/data0/fastcgi_temp_path
Mkdir-p/data0/fastcgi_cache_path
Step Two:
code example:
Nginx configuration file
http{
...
Fastcgi_temp_path ...;
Fastcgi_cache_path ...;
server{
...
Fastcgi_cache Cache_name;
Fastcgi_cache_valid ...;
Fastcgi_cache_key ...;
}
}