Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to open Gzip files for caching

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the relevant knowledge of "how to open Gzip files for caching". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

Open Gzip to Nginx ngx_http_gzip_module module, use nginx-V command to check whether there are configurarguments, if not, you need to compile and load this module.

How to open a Gzip file

Suppose we all already have this module.

Open the configuration file with vim, assuming my nginx.conf is in the/usr/local/nginx directory

vim/usr/local/nginx/nginx.conf

And then, and then, http{} between the braces.

Add the following content, some setting parameters need to be modified according to the site situation, it is recommended to delete comments when adding

gzipon;

#This command is used to turn on or off the gzip module (on/off)

gzip_buffers168k;

#Set up the system to get several units of cache for storing gzip compressed result data stream. 168k represents 16 times the original data size of the installation in 8k units.

gzip_comp_level6;

#gzip compression ratio, the numerical range is 1-9, 1 compression ratio minimum but fastest processing speed, 9 compression ratio maximum but slowest processing speed

gzip_http_version1.1;

#Identify http protocol version

gzip_min_length356;

#Set the minimum number of bytes allowed to compress the page. The number of bytes of the page is obtained from the content-length of the header header. The default value is 0, which compresses pages regardless of size. Here I set it to 256.

gzip_proxiedany;

#Set here to unconditionally enable compression regardless of header header

gzip_varyon;

#Add vary:Accept-Encoding to httpheader for proxy server

Cache Gzip files

Image files, font files, js and css are files that can be used for caching. Here, by setting Expires and Cache-Control headers, you can configure location directly in the configuration file.

location~.*\. (gif|jpg|jpeg|png|bmp|swf|flv|ico)${

expires30d;

access_logoff;

}

location~.*\. (eot|ttf|otf|woff|svg)${

expires30d;

access_logoff;

}

location~.*\. (js|css)?$ {

expires7d;

access_logoff;

"How to open Gzip file cache" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report