How can it be done?
I created a snippet with the code that works on normal php pages and included it in my modx template, but it just gives me a blank page.
Thanks. I’ve read through and used the following code (putting all my code <html> etc where it says code here) and it looks to have worked fine in normal php files.
<?php
$compressed = gzcompress(’code here’, 9);
echo $compressed;
?>
However STILL in modX, I cannot get it to work.
Maybe use a plugin which captures all output before printing it to the screen and then compress it?
-
☆ A M B ☆
- 1,056 Posts
Quote from: sirlancelot at Jul 30, 2007, 12:48 PM
gzcompress() PHP Documentation
Cool. What is the primary difference/benefits opposed to using .htaccess? Never used gzcompress() function myself...
# For servers that support output compression, you should pick up a bit of
# speed but un-commenting the following lines.
php_flag zlib.output_compression On
php_value zlib.output_compression_level 5
Before this thread can move anywhere, we need to know more details about the purpose the script you are writing is going to do. Please describe, and be specific about what/how you want to "implement gzip"
Thanks for the info. I now have a solution (sort of). But since I’ve never compressed any of my MODx websites, I don’t have ALL the details.
My guess is that you’ll need to create a plugin that is triggered by [tt]OnWebPagePrerender[/tt]. It will send [tt]header(’Content-Encoding: gzip’);[/tt] and then compress the content contained in [tt]$modx->documentOutput[/tt].
You first may want to check to make sure the client supports gzip encoding. But here’s a starting point.