简体   繁体   中英

How to serve gzip compressed file on production in angular7

var BrotliGzipPlugin = require('brotli-gzip-webpack-plugin');
module.exports = {
    plugins: [
        new BrotliGzipPlugin({
            asset: '[path].br[query]',
            algorithm: 'brotli',
            test: /\.(js|css|html|svg)$/,
            threshold: 10240,
            minRatio: 0.8
        }),
        new BrotliGzipPlugin({
            asset: '[path].gz[query]',
            algorithm: 'gzip',
            test: /\.(js|css|html|svg)$/,
            threshold: 10240,
            minRatio: 0.8
        })
    ]
}

I am using this code but couldn't able to serve the compressed file on production mode and also using Apache server.

There really isn't enough code here to provide a definitive answer, I think ... but here's where I would start looking: "in the client-side browser logs." You should see an HTTP request going out, and a GZIP-encoded reply coming back with the HTTP header tag Content-Encoding: gzip .

Well, do you see the request going out? Was the return-code 200 OK ? Was the encoding specified? What did the client-side browser actually do? Unfortunately you tell us none of these things.

(Also be mindful that many browser exchanges use gzip encoding routinely for everything. The algorithm's so fast that it's basically free ...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM