nginx static resource services

1. File Compression

LOCATION ~ * \ (JPG | GIF | PNG) $ {.. 
        gzip ON (open); 
        gzip_http_version 1.1 (version); 
        gzip_comp_level 2 (compression ratio); 
        gzip_types (file type) text / plain application / javascript application / x-javascript text / CSS file application / XML text / JavaScript file application / X-PHP the httpd-Image / JPEG Image / Image GIF / PNG; 
        the root / opt / App / code / Images; 
    }

2. Compression ahead function of gzip file

location ~ ^/download {
        gzip_static on(开启);
        tcp_nopush on;
        root /opt/app/code;
    }

3. The browser cache principle

.. ~ LOCATION * \ (HTM | HTML) {$ 
        the add_header the Allow-Access-Control-Origin (cross-domain access request domain name) * (represented by all); 
        the add_header-Access-Control-the Allow Methods (cross-domain access request method ) the GET, the POST, the PUT, the DELETE, the OPTIONS; 
        Expires 24h (buffer cycle); 
        the root / opt / App / code; 
    }

 

Guess you like

Origin www.cnblogs.com/yoyo1216/p/10935408.html