How to Enable Gzip

How to enable GZip compression in XAMPP server

You do compression by setting appropriate directive in apache.

It goes uncommenting the following lines in your apache conf file:
C:\xampp\apache\conf\httpd.conf

if your xampp installation folder is C:\xampp.

and these are the lines to be uncommented first:

LoadModule headers_module modules/mod_deflate.so
LoadModule filter_module modules/mod_filter.so

that is to say, if they have # before them, you should remove them!

Then put this at the end of your httpd.conf file:

SetOutputFilter DEFLATE 

<Directory "C:/your-server-root/manual"> #any path to which you wish to apply gzip compression to!
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html # or any file type you wish
</IfModule>
</Directory>

How to enable gzip compression for PHP-generated pages?

The problem was in shared hosting settings. I contacted the support and they enabled compression for pages.

How to enable gzip?

Have you tried with ob_gzhandler?

<?php ob_start("ob_gzhandler"); ?>
<html>
<body>
<p>This should be a compressed page.</p>
</html>
<body>

As an alternative, with the Apache web server, you can add a DEFLATE output filter to your top-level server configuration, or to a .htaccess file:

<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml \
text/css application/x-javascript application/javascript
</IfModule>

Tip: Sometimes it is pretty tricky to detect if the web server is sending compressed content or not. This online tool can help with that.

Using the developer tools in my web browser, I tested a PHP file with and without compression to compare the size. In my case, the difference was 1 MB (non-compressed) and 56 KB compressed.

how to enable gzip compression in angular cli for production build

You could achieve this with a simple bash script before transferring them to the server, or even adding it to package.json as a command

 "scripts": {
"build.prod": "ng build --environment=prod && tar -zcvf archive.tar.gz dist/prod/*",

Not sure what's your folder structure, but you can play around with tar -zcvf archive.tar.gz dist/prod/* in the terminal until you find paths that suite to your needs.

EDIT: Seems I misunderstood the question, if it is about bundle size when serving the stuff to the end user, you should take a look at AOT + Rollup to minimize your bundle sizes. And enable gzip compression on your webserver when serving files (probably most servers have it enabled already).



Related Topics



Leave a reply



Submit