You are here: Home / What do you need? / Help and documentation / Unix tricks and information / Safari, gzip deflation and blank pages

Safari, gzip deflation and blank pages

by Darrell Kingsley last modified Mar 13, 2014 02:02 PM
Safari shows blank pages with no error message of any sort. Here's why and what to do about it

After investigation of Transfer encoding issues people had had with chunked encoding of content, we decided to try turning off deflation (gzipping) of content by Apache altogether. This fixed the problem, but meant we were eating bandwidth like there was no tomorrow.

Then we tried only gzipping all the text file types i.e. text/plain, text/html, text/css and text/javascript as follows:

   AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript

But that meant that all other types of content were not being gzipped. We'd already put in place filters to prevent gzipping of images, binary media such as .mp4 files etc. and PDFs (because that means Acrobat can't read them), so it seemed a shame to not gzip as much of everything else as we could for all other browsers.

In the end, we settled for a new line in the appropriate part of Apache httpd.conf which restricts gzipping to text/html. It's a shame that other types aren't gzipped too, but it's much better than Safari failing to work at all on our sites. This is the new line:

    BrowserMatch Safari gzip-only-text/html

It fits into httpd.conf as follows:

<Location />
    SetOutputFilter DEFLATE
# Safari only likes text gzipping
    BrowserMatch Safari gzip-only-text/html
    SetEnvIfNoCase Request_URI  \
        \.(?:gif|jpe?g|png)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI  \
        \.(?:mp3|wav|wma|au|m4p|snd|mid|wmv|mpg|mpeg|mp4|qt|mov)$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
    SetEnvIfNoCase Request_URI  \
        \.(?:exe|t?gz|zip|gz2|sit|rar)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
    Header append Vary User-Agent env=!dont-vary

If anyone comes across of better way of achieving the same thing, with more gzipping, please let us know.

If you want to inspect the HTTP headers in Safari 3+ do the following:

Develop > Show web inspector > resources tab >click on a resource in the left hand column > select the headers tab

Also see this for more on deflation: Apache, gzip compression and binary files