|
ReduceBandWidth<< Typing Errors | Cookbook-V1 | Search Highlight >> Note: The recipes here are for PmWiki versions 0.6 and 1.0 only. For PmWiki 2.0 recipes, see Cookbook.
GoalReducing the used bandwidth on the web server.Probably quite a few are on a data-limit. After reaching the data limit, the site either is blocked for a while, or the host requires some extra cash from you. SolutionIt might be possible to reduce the amount of data throughput with very little effort. Most browsers are able to use data compression when transferring data (even IE does). Only thing to do is to have the output of php compressed, depending on the capabilities of the browser making the request. Depending on the compilation of php on your host (PHP compiled with "--with-zlib") this might be as easy as adding: Two requests on my test system, the first without gzhandler:
(The clock is broken on my test machine; this isn't a message from the past :) ) In this case a reduction of 75%, compression depends on your pages, I see reductions between 50% and 80%. Sure, it uses a bit more CPU power on server and client site, but we are on a data-limit, not cpu-limit. Actually transfer of the data could be faster, since we transfer less bits. http://www.php.net/manual/en/function.ob-gzhandler.php Discussion=note Another approach to resolving this problem would be to combine compression with page caching (e.g., SimplePageCache). This would save cpu cycles and time on the server. I may do this as an extension in pmwiki-0.6. --<#> =note Right, in case you are using the SimplePageCache you could modify the ob_start in the cache script as described below. However nesting is allowed with ob_start, so it would work as described as well. BrBrBr =note CPU cycles are generally a non-issue. Modern machines compress content at the rate of several MB per second -- much faster than PmWiki can possibly generate the output. On the other hand, from my reading of the PHP documentation, using ob_start() has the disadvantage of delaying output until the entire page has been generated, which might be undesirable for long pages. To avoid this, it might be necessary to use mod_gzip instead. -- Reimer Behrends =note Thanks for the extra information. Compression does put an extra load on the machine, regardless how fast it is. You are right that the extra effort should not be an issue. (Unless you have to pay for cpu-cycles like in my old VAX-VMS times) How to check zlibCreate a script (test.php or whatever you like) and put it on your server: <? phpinfo(); ?> look for zlib How to check the resultIn case you can see the raw log files, simply look at the size before and after adding the gz-handler. AlternativeAn alternative is to install and enable mod_gzip in the Apache configuration. This will transparently compress anything served by Apache that is compressible. pmwiki-2.2.0-beta68 -- Last modified by {{Anno}}
|