Quantcast
Channel: DevOps | Phil Chen
Viewing all articles
Browse latest Browse all 20

Apache Mod_Deflate and Flash SWF Files Don’t Like Each Other

$
0
0

Recently I was working on a Flex project and upon completion and successful QA, I deployed it on a clients server for use. After embedding the SWF file and adding the data.xml that populated the flash application, I could not load the application in Firefox or IE. Several refreshes would load the application occasionally, however most of the time I just had a grey box.

So while troubleshooting using Firebug, I realized that the clients server I had deployed on was using Apache 2.2.11 with Mod_Deflate enabled, a method commonly used to compress up to 70% of data transfered over the wire to speed page loads. I then had a flash back on reading an article about issues with compression of SWF’s, and upon further investigation of the clients Apache configuration file I saw SWF was not excluded from compression via Mod_Deflate.

Mod_Deflate was compressing SWF files sending them with chunked transfer encoding to the browser. It appears the last part of the chunk was being missed by the browser. By refreshing the browser cache it sometimes filled in the missing chunk, and displayed the application.

So I added SWF to the list of files not to compress via Mod_Deflate and the application worked perfectly everytime.

Below is the section I added the SWF exclusion:

BEFORE:


# Insert filter
SetOutputFilter DEFLATE

# 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

# Don't compress images and other uncompressible content
SetEnvIfNoCase Request_URI \
 \.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|avi|mp?g)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

AFTER:



# Insert filter
SetOutputFilter DEFLATE

# 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

# Don't compress images and other uncompressible content
SetEnvIfNoCase Request_URI \
 \.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|avi|swf|mp?g)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary

The post Apache Mod_Deflate and Flash SWF Files Don’t Like Each Other first appeared on Phil Chen.

Viewing all articles
Browse latest Browse all 20

Trending Articles