Nginx static compression (ngx_http_gzip_static_module)

Source: Internet
Author: User
Tags auth gz file

When constructing squid web page acceleration, compress large css or js files and then cache them. This increases the page response speed by reducing the download volume. If you are using a version earlier than squid 3.0 and use an ngnix server, you may encounter the following problems: if you do not need squid to open the page directly, the client returns the compressed state, if squid acceleration is enabled, the downloaded page is not in the compressed state. This is mainly because the ngnix static cache module (ngx_http_gzip_static_module) is not started.

Solve the static cache problem.

1. nginx compilation options

The code is as follows: Copy code
./Configure -- with-http_gzip_static_module

2. Modify nginx. conf

The code is as follows: Copy code

Gzip_static on;

Gzip_http_version 1.1;
Gzip_proxied expired no-cache no-store private auth;
Gzip_disable "MSIE [1-6].";
Gzip_vary on;

# Pre-compressed files cannot be found for dynamic compression

Gzip on;
Gzip_min_length 1000;
Gzip_buffers 4 16 k;
Gzip_comp_level 5;
Gzip_types text/plain application/x-javascript text/css application/xml;
 
# Gzip public configuration

Gzip_http_version 1.1
Gzip_proxied expired no-cache no-store private auth;

 
 

For requests that support gzip, the reverse proxy cache server will return gzip content. Clients that do not support gzip will return the original content.

Gzip_vary on;

1.gzip _ static configuration has a higher priority than gzip
2. After nginx_static is enabled, you will first check whether a corresponding gz file exists for any file.
3.gzip _ types settings are invalid for gzip_static

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.