Search This Blog

Wednesday, May 16, 2012

mod_deflate configuration. Error playing .swf (flash)

Apache v2 module Deflate.

Today I stuck on something very strange.
Server whom I worked on it, run's WHM and on one of the websites, I saw follow issue:
Main page running .swf files, I mean flash. When I open the website in google chrome and internet explorer,  I see blank grey page while in FIREFOX it works fine.

               What is the problem here?

First I checked which modules installed on this server by httpd –l command.
Afterwards, I dug from network something interesting and I tried to resolve this issue. So better  Keep it for your self.
On this server installed mod_delflate.

Quote from WIKI:
"mod_deflate is an optional module for the Apache HTTP Server, Apache v2 only. Based on Deflate lossless data compression algorithm that uses a combination of the LZ77 algorithm and Huffman coding.This module provides the DEFLATE output filter that allows output from Apache HTTP server to be compressed before being sent to the client over the network.It also provides a filter for decompressing (inflating, uncompressing) a gzip compressed response body.The mod_deflate module does not have a lower bound for file size, so it attempts to compress files that are too small to benefit from compression. This results in files smaller than approximately 120 bytes becoming larger when processed by mod_deflate"
To resolve this problem, you need to edit  /usr/local/apache/conf/includes/post_virtualhost_global.conf
Add SWF extension to  "Don't compress images"
Here is my example:

<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
<IfModule mod_setenvif.c>
# 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
# Don’t compress images
SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|swf)$ no-gzip dont-vary
</IfModule>
<IfModule mod_headers.c>
# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>

Exit from editor, save and restart httpd.
/etc/init.d/httpd restart
Refresh your website, it's should be ok.
eNj0y!

No comments:

Post a Comment