Revision history for LetterSaladOutputWorkaround


Revision [18263]

Last edited on 2008-01-28 00:10:56 by JavaWoman [Modified links pointing to docs server]

No Differences

Revision [5256]

Edited on 2005-01-27 00:44:13 by JavaWoman [initial]
Additions:
=====Only letter salad in the browser=====
After installation, when accessing the Wikka main URL (or any page for that matter) only results in garbage characters ("letter salad") in the browser window (looks like viewing a binary file).
In fact, what you're seeing **is** a binary file, a gzipped file more precisely. This happens when the **server** (or PHP) is set to serve files gzip-encoded, and Wikka (with its default setting to allow gzip encoding) detects that it is available - the result is that Wikka does its own gzip-encoding, and then the server does it again, while the browser of course **de**codes it only once.
Any Wikka version.
There are actually two possible solutions; which one is best depends on the context Wikka is used in:
~-If Wikka is the only (or main) application running on a server, you could turn off the server-configured gzip encoding; how, depends on how it's configured, of course.
~-If gzip encoding needs to remain active at the server / PHP level, you can configure Wikka not to do its own gzip encoding; two simple changes are needed:
~A new configuration value and a small change in the code can be used to tell Wikka not do do gzip encoding even if it's available and the browser accepts it. //(Note: this solution parallells that on BlankPageWorkaround.)//
~==Configuration==
~First, open **##/wikka.config.php##** (after allowing write access on it!) and find the line %%(php) "wikiping_server" => "",%% (or possibly there's a value after the **##=>##**) and add the following line right after it: %%(php) "allow_gzip" => "0",%% to indicate you don't want Wikka do so its own gzip encoding. (Make the file read-only again after editing it).
~==Main program==
~Then open **##/wikka.php##** and find this code at the end: %%(php)$content = ob_get_contents();
if (strstr ($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') )
{
// Tell the browser the content is compressed with gzip
header ("Content-Encoding: gzip");
$page_output = gzencode($content);
$page_length = strlen($page_output);
} else {
$page_output = $content;
$page_length = strlen($page_output);
}
// header("Cache-Control: pre-check=0");
header("Cache-Control: no-cache");
// header("Pragma: ");
// header("Expires: ");
$etag = md5($content);
header('ETag: '.$etag);
header('Content-Length: '.$page_length);
ob_end_clean();
echo $page_output;%% and change it as follows: %%(php)$content = ob_get_contents();
// if server/PHP already does gzip encoding we prevent Wikka doing it as well by setting 'allow_gzip' to '0' in the configuration
if (strstr ($HTTP_SERVER_VARS['HTTP_ACCEPT_ENCODING'], 'gzip') && function_exists('gzencode') && $wakka->config['allow_gzip'] == '1')
{
// Tell the browser the content is compressed with gzip
header ("Content-Encoding: gzip");
$page_output = gzencode($content);
header('Content-Length: '.strlen($page_output));
} else {
$page_output = $content;
// if server does gzip encoding we don't want content-length calculation to prevent a wrong byte count to be sent to the browser
if ($wakka->config['allow_gzip'] == '1')
{
header('Content-Length: '.strlen($page_output));
}
}
// header("Cache-Control: pre-check=0");
header("Cache-Control: no-cache");
// header("Pragma: ");
// header("Expires: ");
$etag = md5($content);
header('ETag: '.$etag);
//header('Content-Length: '.$page_length); # moved
ob_end_clean();
echo $page_output;%%
~==Changed situation?==
~If later the server-level gzip encoding is no longer done (or you move Wikka to a different server where this isn't configured), just change the config to set 'allow_gzip' to '1' and you'll get gzip encoding in Wikka enabled again, as well as content-length calculation. Using Gzip encoding costs a little extra in CPU but saves on bandwidth.
Deletions:
=====Problem description=====
//This page is a **template** intended for documentation of **workarounds** for unusual Wikka problems. This page belongs to CategoryTemplate (which contains more handy templates). To create a Wikka **workaround** page, [[http://wikka.jsnx.com/WorkaroundTemplate/clone clone this page]] (most workaround page names end in 'Workaround' so it's useful to stick to that convention) and replace the title with a problem description (in a few words). Then remove this paragraph and provide actual page content in the outline below.//


Revision [5255]

The oldest known version of this page was created on 2005-01-26 23:49:55 by JavaWoman [initial]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki