does anyone know how to enable gzip text compression in nginx and universal angular? I don't know where to start doing it
does anyone know how to enable gzip text compression in nginx and universal angular? I don't know where to start doing it
The gzip has nothing to do with Angular, it's a server thing.
In nginx you can enable it by setting gzip on;
Like below:
server {
gzip on;
gzip_types text/plain application/xml;
gzip_proxied no-cache no-store private expired auth;
gzip_min_length 1000;
...
}
See the article below for more details:
https://docs.nginx.com/nginx/admin-guide/web-server/compression/
First step is edit nginx.conf file, that could be located /etc/nginx/nginx.conf or /usr/local/nginx/conf/nginx.conf, in most distributions.
Open nginx.conf file with your favorite editor. You can see that there’s already a block of settings regarding Gzip; you could always just modify those and un-comment out the lines as shown below :
# enable gzip compression
# Turns on/off the gzip compression.
gzip on;
# Compression level (1-9).
# 5 is a perfect compromise between size and cpu usage, offering about
# 75% reduction for most ascii files (almost identical to level 9).
gzip_comp_level 5;
# The minimum size file to compress the files.
gzip_min_length 1100;
# Set the buffer size of gzip, 4 32k is good enough for almost everybody.
gzip_buffers 4 32k;
# Compress data even for clients that are connecting to us via proxies,
# identified by the "Via" header (required for CloudFront).
gzip_proxied any;
# This directive let you specify which file types should be compressed, in this case plain text, js files, xml and #css.
gzip_types text/plain application/x-javascript text/xml text/css;
# Enables response header of “Vary: Accept-Encoding
gzip_vary on;
# end gzip configuration
Once your done with above config changes, restart or reload your server and you will now be serving site assets with gzip compression.
/etc/init.d/nginx reload
or
sudo service nginx restart