Nginx server sets static page compression cache and expiration time

Set static page compression cache and expiration time settings in nginx: Friends who use the nginx server may know that it is necessary to set the html static page cache, page compression and expiration time settings. Let me introduce the configuration method to you, including ico, gif, bmp, jpg, jpeg, swf, js , css, mp3 files are cached locally. You can use nginx to set the expiration time of the static resources on the server and compress and transmit the resources to reduce the bandwidth overhead of the server. The following is how nginx sets the expiration time of static resources: location ~* .(ico|gif|bmp|jpg|jpeg|png|swf|js|css|mp3) { root /var/www/opkeep; expires 30d; } The above configuration can cache ico, gif, bmp, jpg, jpeg, swf, js, css, mp3 files locally, without re-acquiring them from the server every time they are accessed. The compressed configuration is as follows: gzip on; gzip_min_length 1000; gzip_buffers 4 8k; gzip_types text/plain application/x-Javascript text/css; Compress text, js and css files. Generally, the compressed size is 25% of the original size, or even smaller. Cache dynamic pages, cache expiration time Here is the configuration of the virtual machine: nginx configuration file content: Mainly this sentence: proxy_cache_path /www/ levels=1:2 keys_zOne=Z:10m inactive=1m max_size=30g;…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索