-
The Previous Posting
« The Correct Way To Set Up gzip with Magento -
The Next Posting
Force Nextgen Gallery To Crop Thumbnails From The Top Of The Image… **Updated** »
Utilizing GZip with WordPress, Finally a Fast Blog…
The first half of this article will be taken directly from our previous post, as the need for a single default php.ini is necessary to configure gzip. If reading our Magento post is what brought you to the site, and you’ve already configured your default php.ini, than skip to the .htaccess portion of the post. Otherwise, were off…
The majority of people reading this article with be on a shared hosting platform. So we’ll be explaining the steps in those terms. If you don’t already know whether gzip is available on your server, copy the following code to an html editor, or a text editor, and save it as test.php.
1 2 3
<?php phpinfo(); ?>
Load the file to your server, and navigate to it with you web browser. If you see gzip anywhere on the info page, your in luck. Remember to remove this file before moving on, as it does pose a security threat if left on the server.
Next you need to log into you hosting account and access your cpanel. Keep in mind that most good hosting companies will help you with all of this, so never be ashamed to for help.
The first thing we need to do is install a Single Default ini. Log into your cpanel, and choose php config, under your softwares / services panel. , and always remember to backup your files and databases frequently. Make sure your sites are all running PHP5, and choose (Single php.ini) Choose save, and scroll down. To complete the install. and then select IonCube and SourceGuardin and click “Install php.ini Master File”. This manually directs system resources to the new location of your single php.ini file. Call your host if you need help. Download the file from the root directory of your server ( php.ini.default ) Next rename the file to php.ini and open it. Locate the memory settings, Currently located on line 227. Your location may vary.
227 228 229 230 231 232 233
;;;;;;;;;;;;;;;;;;; ; Resource Limits ; ;;;;;;;;;;;;;;;;;;; max_execution_time = 30 ; Maximum execution time of each script, in seconds max_input_time = 60 ; Maximum amount of time each script may spend parsing request data memory_limit = 32M ; Maximum amount of memory a script may consume (32MB)
and change the default memory from a whopping default of 32m to a minimum of 64m in a busy environment, or preferably to something like 128m, or even 256m if running a sizable store on a stand alone server. Setting the ram even higher can lead to system instabilities, and intervention by your system admins. With this default ini in place, you’ve now set a global memory setting, across every folder on your server. This is a sure fire way to eliminate freezing during checkout, and other random Magento weirdness.
Another option while here would be to increase execution time. While not necessary, especially with our now increased Ram, our suggestion would be nothing more than 120 seconds. If you’ve got a script running longer than a minute or two, there’s probably something wrong, and a forced stop is in order.
Now that we’ve got more memory, and and in turn improvement in stability, and reliability, lets really make this thing really boogie. With our default ini still open, search for ob_gzhandler This is also an area where you’ll see a mention of the use of either gzip or zlib, and never both. Duplicate the line containing the following script. Currently located on line 106. Your location may vary.
output_handler = ob_gzhandler
104 105 106 107 108 109 110 111 112 113 114 115 116 117
; Note: You cannot use both "mb_output_handler" with "ob_iconv_handler" ; and you cannot use both "ob_gzhandler" and "zlib.output_compression". output_handler = ob_gzhandler ; Transparent output compression using the zlib library ; Valid values for this option are 'off', 'on', or a specific buffer size ; to be used for compression (default is 4KB) ; Note: Resulting chunk size may vary due to nature of compression. PHP ; outputs chunks that are few hundreds bytes each as a result of ; compression. If you prefer a larger chunk size for better ; performance, enable output_buffering in addition. ; Note: You need to use zlib.output_handler instead of the standard ; output_handler, or otherwise the output will be corrupted. zlib.output_compression = Off
Notice zlib is either commented out, or off. Be sure it stays this way. With your PHP.ini now finished, reload it to the root of your server. This one file provides the single largest performance and stability improvement you will find with Magento.
Now we talk about WordPress. Retrieve your .htaccess file from the root of your WordPress install, and copy paste the script below to theend of your .htaccess file. Duplicate the settings you see below. While we’re on the subject of memory speed, an article we wrote a few moths back may also interest you. In the article titled WordPress, Fatal error: Allowed memory size of 33554432 bytes exhausted We describe how to increase the memory allocated to wordpress.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
<IfModule mod_gzip.c> mod_gzip_on Yes mod_gzip_can_negotiate Yes mod_gzip_static_suffix .gz AddEncoding gzip .gz mod_gzip_update_static No mod_gzip_command_version '/mod_gzip_status' mod_gzip_keep_workfiles No mod_gzip_minimum_file_size 512 mod_gzip_maximum_file_size 1048576 mod_gzip_maximum_inmem_size 60000 mod_gzip_min_http 1000 mod_gzip_handle_methods GET POST mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^httpd/unix-directory$ mod_gzip_item_include file \.shtml$ mod_gzip_item_include file \.html$ mod_gzip_item_include mime ^application/x-javascript$ mod_gzip_item_include mime ^application/javascript$ mod_gzip_item_include file \.js$ mod_gzip_item_include file \.css$ mod_gzip_item_include mime ^application/x-httpd-php$ mod_gzip_item_include file \.php$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_dechunk Yes mod_gzip_item_include mime ^image/.$ mod_gzip_item_include mime ^image/ mod_gzip_item_include rspheader Content-Type:image/* </IfModule>
The very blog you’re reading from now is even utilizing this fix. Be aware, if you have a script intensive, or photography site, you may want to exclude that content from gzip. This is easy enough to do by simply replacing the word include with exclude. Tough fix huh? Hopefully we were able to help you, let use know with a comment.
And if you’d like to see the results first hand, simply copy & paste you’re websites URL to anyone of the following links. Thanks for stopping by.