nginx static separation, optimization

 

location = / {
root D:/project/application/meal/WebRoot;
index index.html index.htm;
#expires 7d;
}

 

location ~ .*\.(js|css|jpg|jpeg|png|html)?$ {
root D:/project/application/webapp/WebRoot;
index index.html index.htm;
}

 

location ~ {
proxy_pass http://127.0.0.1:8080;
}

 

css / js compression

     # Opening and closing mode gzip 
    gzip ON; 
    
    #gizp compression starting point, only compressed file is larger than 1k 
    gzip_min_length 10K; 
    
    # gzip compression levels 1-9 , the higher the number the better the compression, the more CPU time 
    gzip_comp_level 1 ; 
    
    # be compressed file types. 
    text gzip_types / Plain the Application / JavaScript the Application / the X-text-JavaScript / CSS the Application / xml text / JavaScript; 
    
    #nginx processing module for static files, will look after opening a file ending in .gz, direct return, will not be occupied by cpu compression, compression is not performed if no 
    gzip_static OFF; 
    
    # whether to add the http header Vary in: the Accept - Encoding, is recommended to turn 
    gzip_vary oN; 

    # set the compression buffer size needed to 4k as a unit, if the file is 7k the application 2 * buffer is 4k 
    gzip_buffers 2 4k;

    # Gzip compression settings for the HTTP protocol version of 
    gzip_http_version 1.1;

 

Guess you like

Origin www.cnblogs.com/whm-blog/p/11968648.html