How to enable GZip compression in Zend Server CE - flash-builder

I work with Falsh buider and httpserver.
To accelerate result display, I'd like to activate compression on Zend Server.
I create .htaccess on /usr/local/zend/apache2/htdocs/, like this:
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
# Insert filter on selected content types only
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xml
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
I restart zend server, but compression seems to be desable.
Indeed on log, file size is the with compression and without.
So can you help me to solve that.
Thanks

You may need to add
AddOutputFilterByType DEFLATE application/x-amf
since you may be indicating that you are using Flash remoting

According your comment, I modify httpd.conf like that:
LoadModule deflate_module modules/mod_deflate.so
<Location />
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/xml application/xml application/x-amf
</IfModule>
</Location>
Now delate_module is loaded.
But when I launch httpservice from flex with e4X resultformat, result file has same size that without compression, Why?
Thanks for helping

Related

How to disable gzip compression in htaccess for a folder

I am looking to disable the gzip folder for folder xxx. looking in StackOverflow, I have tried this :
SetEnvIf Request_URI ^/xxx(.*) no-gzip dont-vary
But it doesn't work.
I have added in here :
<IfModule mod_deflate.c>
SetEnvIf Request_URI ^/flipbook(.*) no-gzip dont-vary
# enables the filter
SetOutputFilter DEFLATE
# non-textual entities should be already compressed
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
and even outside the mod_deflate module but nothing works.
Could anyone help?
SetEnvIf Request_URI ^/flipbook(.*) no-gzip dont-vary
This looks like it should work - for any URL that starts /flipbook (case-sensitive). Setting the no-gzip environment variable disables the DEFLATE filter of mod_deflate.
However, the (.*) part on the regex is entirely superfluous. And, unless you are specifically using the dont-vary env var in your own directives then this isn't doing anything. I don't think dont-vary is a "special" Apache env var. Apache has force-no-vary, which does what dont-vary is probably intended to do, however, I don't believe you should be disabling the Vary header anyway since mod_deflate applies the filter based on the Accept-Encoding HTTP request header sent from the client, so any intermediary caching proxies should cache based on this header. (Only certain proxies have a problem with this header.)
So, this should be written:
SetEnvIf Request_URI "^/flipbook" no-gzip
Reference:
https://httpd.apache.org/docs/2.4/env.html#special
# enables the filter
SetOutputFilter DEFLATE
This doesn't just "enable the filter", it enables the DEFLATE filter on all responses. This basically renders the AddOutputFilterByType directives that follow superfluous, since you are already setting DEFLATE on everything. Generally, you don't want to set it on everything, which is presumably why you are using the AddOutputFilterByType directives.
So, you probably don't need the SetOutputFilter directive, if you are setting the DEFLATE on specific mime-types. OR, you use SetOutputFilter and remove the AddOutputFilterByType directives, but then you should still disable the filter on images and other already compressed media using the no-gzip env var.
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
You don't need all 3. Your server is setting just one mime-type when sending JavaScript files - which you can see in the HTTP response. You only need that one. (Probably application/javascript.)
Alternative solution
Instead of setting the no-gzip env var to disable mod_default, you could instead use an Apache <If> expression to conditionally set the output filters only when not accessing URLs that start /flipbook.
For example:
<If "%{REQUEST_URI} !~ m#^/flipbook/#">
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/javascript
</If>
You don't really need the <IfModule> wrapper unless you intend to port the same code to multiple servers where mod_deflate might not be enabled (and that is acceptable).

Problem with mod_deflate - compressing executable file

When trying to download file with.EXE extension in the site, the files are coming as .GZ
Environment
Centos 7 64
Apache 2.4.6
Changing the file in /etc/httpd/conf/httpd.conf I have already tried using each of these forms below, however, to no avail (I restarted apache and deleted the browser cache on each attempt):
1:
SetEnvIfNoCase Request_URI \.exe$ no-gzip dont-vary
2:
<FilesMatch \.exe$>
SetEnv no-gzip 1
</FilesMatch>
3:
SetEnv mod_deflate off
4:
SetEnv no-gzip off
5:
In the file /etc/httpd/conf.modules.d/00-base.conf I commented:
LoadModule deflate_module modules/mod_deflate.so
6:
I tried to delete the file, but it did not work.
/usr/lib64/httpd/modules/mod_deflate.so
I was reviewing httpd.conf and when I removed the addtype directive (AddType application / x-gzip .tgz .rar .zip .exe .dll) the EXE file was no longer compressed.
I had put this because the browser was taking too long to start the download EXE, in addition, RAR file instead of downloading, was being displayed as a binary in the browser.
So I did the following to solve (I do not know if it was the indicated output, but my knowledge is not enough, I'm new in this area):
<IfModule mod_deflate.c>
# compress text, html, javascript, css, xml...:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch ^HMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|zip|bz2|rar|exe|pdf|doc|dll|jpg|sit|mp4|mov|mp3|3gp|webm|rm|avi|ogv)$ no-gzip dont-vary
<FilesMatch \.exe$>
ForceType application/exe
Header set Content-Disposition attachment
</FilesMatch>
<FilesMatch \.rar$>
ForceType application/rar
Header set Content-Disposition attachment
</FilesMatch>
</IfModule>

Apache gzip SOAP

I am new to Apache and I am trying to figure out how to enable gzip compression to send data over to clients (.NET Compact Framework devices).
I am using Apache 2.2 and so far, I have enabled mod_deflate.so but my content send over netwrok is not gzipped.
Any idea? much appreciated
UPDATE
I am on Windows using Apache 2.2. In my httpd.conf file, I uncommented this line.
LoadModule deflate_module modules/mod_deflate.so
My module Location is in httpd.conf file like this:
<Location /MyModule>
SetHandler mod_MyModule-handler
</Location>
And in httpd.conf file, I already had all this, so nothing was changed here except that I have uncommented DeflateCompressionLevel 9:
<Location />
# Insert filter
SetOutputFilter DEFLATE
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
AddOutputFilterByType DEFLATE application/x-javascript
#DeflateCompressionLevel 9 //if I uncomment this, server wont start
# 1 to 9: 9 is the most compressed
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
#The following statement indicate which document types not to compress. Many type of documents do not compress well.
#At the end (Appendix 1) of this article some more type you might wish to also exclude from compression
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
# install/enable the Apache module mod_headers
Header append Vary User-Agent env=!dont-vary
# install/enable the Apache module LoadModule expires_module modules/mod_expires.so
# turn on the module for this directory
ExpiresActive on
# set defaults
ExpiresByType text/javascript "modification plus 11 months"
ExpiresByType application/javascript "modification plus 11 months"
ExpiresByType text/css "modification plus 11 months"
</Location>
Then I restart Apache, send request to it and receive response but response.ContentEncoding does not show "gzip" in .NETCF client. It looks like I am missing something.
uncomment the deflate module
LoadModule deflate_module modules/mod_deflate.so
and add this stanza to the virts config like this (be sure to include your soap mime type)
<IfModule deflate_module>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
</IfModule>
bash test
function check_compression {
curl -s -k -I -H 'Accept-Encoding: gzip,deflate' $1 |grep "Content-Encoding"
}
check_compression http://your.url.com
If that doesn't work, check that you have the mime type set correctly for the soap response.

mod_deflate disabled: assets still being gzipped

When I execute:
sudo a2dismod deflate
sudo service apache2 restart
And refresh & inspect the response headers of my site in Chrome Web Tools, my assets (css and js) are still being marked as Content-Encoding : gzip. Y-Slow also confirms that all assets except the actual html document are still compressed.
I have output compression turned off in CodeIgniter's config file:
$config['compress_output'] = FALSE;
For what it's worth... though with the deflate module disabled I don't think it matters much, my /etc/apache2/mods-available/deflate.conf file is the system default:
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
AddOutputFilterByType DEFLATE application/rss+xml
</IfModule>
I'm running Ubuntu 12.04. What else could be causing my assets to be compressed?
My .htaccess file is void of deflate commands.
You can try the following.
to disable the gzip for a specified file try this:
SetEnvIfNoCase Request_URI YOUR_FILE_NAME\.php$ no-gzip dont-vary
in you htaccess file. change YOUR_FILE_NAME\.PHP$ to what you need.
and to disable the gzip at all try this:
SetEnv no-gzip dont-vary
in your htaccess file.

Enable mod_deflate

I am trying to enable mod_deflate. I have Apache 2.0+ and tried this code in my .htaccess file:
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css
<FilesMatch "\\.(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>
It did not compress any of my files when I tested my site in firebug. What am I doing wrong?
As this'll be moved to SF soon, Shouldn't it be:
<FilesMatch "\.(js|css|html|htm|php|xml)$">
Otherwise the regex becomes \.js, for example (because you've escaped the '\').
SetOutputFilter DEFLATE
I used this and it worked. It was an internet history problem. My yahoo Yslow was saving the results from the first check so when I modified the htaccess the difference did not show up.