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
I just ran into this problem myself. I spent four days debugging until I finally realized what was going on.
I’m surprised this isn’t documented more, your’s is only one of two sites I could find that even mention it.
Thanks for the info
I was thinking of adding swf to gzip in the hopes it would speed things up
so does compressing gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|avi|swf really not help at all
Thanks for this info. I’ve been experiencing this issue with preloading Adobe Captivate e-learning lessons (SWFs). There is a huge latency before the file begins playing, no matter what you set the preloader percentage to. However, in my case I do not have access to the Apache server HTTP.conf file to alter the settings across the server because I’m using a hosting service. Is there a way you know of to add similar exclusions to a .htaccess file on my website so that mod_deflate ignores flash SWF files?
Hi Rod I don’t think you can use a .htaccess file for the exclusions but I could be wrong. I just have never done it that way. Part of the reason I like to have root on a dedicated server, so that I can have a more custom apache build.
I just talked with my hosting company and they do not seem to be willing to change the http.conf file because it affects every single account they have (gee, so they want ALL of their customers to have a problem?!)
They said that a change could be made with an .htaccess file, but have no info on how to make that happen.
I’m not a programmer. If anyone has any suggestions that would be awesome.
Awesome, exactly what I was looking for. Thanks!