Recent Changes - Search:




Summary: Save wiki pages/files in compressed (gzip) format
Prerequisites: Requires at least PmWiki version: 2.0.0; last tested on PmWiki version: 2.2.0beta50

Question answered by this recipe

PmWiki saves its pages in flat files -- Is there any way to store those files in compressed (gzip) format?


The pagestoregz.phpΔ script defines an alternate storage mechanism for storing pages as compressed files in the wiki.d/ directory. To use this script, simply place it in your cookbook directory and add the following lines to local/config.php:


There's no need to convert or modify your existing pages; pagestoregz.php can read existing (uncompressed) pages without any difficulty. As pages are edited and saved, they will be then be saved as compressed files in wiki.d/. Please make sure the above cookbook script is loaded before other scripts or localization files, otherwise changed localizations will not display.

If you want to read compressed files and save them uncompressed, just add the following line to local/config.php

    $EnablePageStoreGZ = 0;

If you want to compress or uncompress all of your files at once add the following line to local/config.php:


Depending in the state of $EnablePageStoreGZ all your files are compressed or uncompressed.

By default compressed files are reread and checked for size difference. If the difference is too high it is assumed that the saved file was corrupted or something else went wrong. You'll then get a message that saving was not possible. As this consumes some time you can switch off this behaviour by setting the following value. But be careful! Once a file is corrupted you are not able to restore it (except from a backup).

    $EnablePageStoreVerify = 0;    // Disables verification of saved compressed file



  • 2005-01-26 Added Variable $CompressPagesOnSave which controls whether the pages are compressed when saved or not (default=1 : compress on save). Nice if you want to switch back to uncompressed later. Added also a function ConvertGZ which compresses/uncompresses all existing pages.
  • 2005-01-27 Found a problem and fixed it: When copying compressed files from a linux server to a windows server the files were not readable due to different end-of-line characters (at least I think this is the reason). Now LF is assumed as end-of-line character when reading compressed files.
  • 2005-04-13 Updated script to contain same optimizations in storage as introduced with PmWiki 2.0 beta 29. (Still no problems with this script Klonk)
  • 2005-09-02 Updated script to changed storig format as introduced with PmWiki 2.0.0 Klonk
  • 2005-09-03 Updated script to changed storig format as introduced with PmWiki 2.0.2 Klonk
  • 2005-09-05 Added switchable checking when saving compressed files. Klonk
  • 2005-09-09 Updated script to match pmwiki-2.0.5 save algorithm and correct handling of $Newline, changed name of flag variables to be $EnablePageStoreGZ and $EnablePageStoreVerify (to match PmWiki's configuration variable conventions).

See Also


  • Pm, 2005-01-14 (original script)
  • Klonk, 2005-01-26 (added $CompressPagesOnSave variable and ConvertGZ function)
  • Pm, 2005-09-09 -- updates for 2.0.5


See discussion at CompressedPageStore-Talk

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on September 02, 2012, at 09:34 PM