Within the server{} of the configuration file, add one sentence:
The code is as follows |
Copy Code |
Location ~. * * *. (CSS|JS) $ { Add_header Cache-control ' No-store '; } |
Add the following code to the HTTP block in the nginx.conf
#proxy_temp_path和proxy_cache_path指定的路径必须在同一分区
Proxy_temp_path/tmp/proxy_temp_dir;
#设置名称为nginx_cache, the memory cache space size is 500mb,30 Day has not been accessed automatically clear, hard disk cache space size of 30GB.
Proxy_cache_path/tmp/proxy_cache_dir levels=1:2 keys_zone=nginx_cache:200m inactive=3d max_size=30g;
Add the following code to the server
The code is as follows |
Copy Code |
Location/{ Proxy_cache Nginx_cache; Proxy_cache_key $host $uri$is_args$args; Proxy_set_header Host $host; Proxy_set_header x-forwarded-for $remote _addr; Expires 30d; } |
Restart Ngnix
code is as follows |
copy code |
/usr/local /nginx/sbin/nginx-s Reload |