G-zip And Mobile Phones

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    G-zip And Mobile Phones

    Hi all! ;)

    Do you use gzip compression when rendering php pages? If so, what's your experience with gzip support in mobile phones?

    I'm about to use it in a XHTML Mobile site, but I want to know more about mobile compatibility.

    What do you think, does it worth?

    Thanks!

    #2
    just enable the mod_deflate module within apache and the difference is minimal with small sites

    Comment


      #3
      <div class='quotetop'>QUOTE (amylee @ Sep 7 2008, 07:07 PM) <{POST_SNAPBACK}></div>
      just enable the mod_deflate module within apache and the difference is minimal with small sites[/b]
      minimal? lol

      I test it with a forum page on lavaliar xhtml.

      without gzip: 12 kb = 100 %
      with gzip compressed: 3kb = 25 %


      This is a very great difference. In GPRS-mode your users can save much money with gzip on.


      Here a hint to enbable gzip on your servers:

      In Apace2 mod_deflate should be installed by default.

      Activate it in your server-terminal:
      Code:
      a2enmod deflate
      Restart apache:
      Code:
      /etc/init.d/apache2 force-reload
      add the following lines to the bottom of your .htaccess:
      Code:
      AddOutputFilterByType DEFLATE text/html
      AddOutputFilterByType DEFLATE text/plain
      AddOutputFilterByType DEFLATE text/xml
      AddOutputFilterByType DEFLATE text/css
      AddOutputFilterByType DEFLATE text/javascript
      AddOutputFilterByType DEFLATE application/x-javascript
      AddOutputFilterByType DEFLATE application/xml
      AddOutputFilterByType DEFLATE application/x-httpd-php
      The javascript lines are optional.

      After that, you can test the gzip compression here:
      gzip test

      Comment


        #4
        u can also do it by using
        Code:
        ob_start("ob_gzhandler");
        function to gzip output buffer.
        ob_gzhandler() requires the zlib extension.You cannot use both ob_gzhandler() and zlib.output_compression. Also note that using zlib.output_compression is preferred over ob_gzhandler().

        here is an another method of doing gzip compressions of your web pages
        Code:
        <?
        // -------------------------------------------------------------------------------------
        $EnableGZipEncoding = true;
        // -------------------------------------------------------------------------------------
        // Helper function to detect if GZip is supported by client!
        // If not supported the tricks are pointless
        function acceptsGZip(){
        $accept = str_replace(" ","",
        strtolower($_SERVER['HTTP_ACCEPT_ENCODING'])
        );
        $accept = explode(",",$accept);
        return in_array("gzip",$accept);
        }
        // -------------------------------------------------------------------------------------
        function playWithHtml($OutputHtml){
        // This will mess up HTML code like my site has done!
        // View the source to understand! All ENTERs are removed.
        // If your site has PREformated code this will break it!
        // Use regexp to find it and save it and place it back ...
        // or just uncomment the next line to keep enters
        // return $OutputHtml;
        return preg_replace("/\s+/"," ",$OutputHtml);
        }
        // -------------------------------------------------------------------------------------
        function obOutputHandler($OutputHtml){
        global $EnableGZipEncoding;
        //-- Play with HTML before output
        $OutputHtml = playWithHtml($OutputHtml);
        //-- If GZIP not supported compression is pointless.
        // If headers were sent we can not signal GZIP encoding as
        // we will mess it all up so better drop it here!
        // If you disable GZip encoding to use plain output buffering we stop here too!
        if(!acceptsGZip() || headers_sent() || !$EnableGZipEncoding) return $OutputHtml;
        //-- We signal GZIP compression and dump encoded data
        header("Content-Encoding: gzip");
        return gzencode($OutputHtml);
        }
        // This code has to be before any output from your site!
        // If output exists uncompressed HTML will be delivered!
        ob_start("obOutputHandler");
        // -------------------------------------------------------------------------------------
        ?>

        Comment


          #5
          i tried to test my website with -


          here is the result

          Web page compressed? Yes Compression type? gzip Size, Markup (bytes) 4,822 Size, Compressed (bytes) 902 Compression % 81.3

          but does it really works i am confused. does it really works with the mobile phones ?

          Comment


            #6
            Well Nice reply Anshul my dear .lol., are you sure it will work with all Mobile cell phone ?? Nokia has problem with Gzip even they support Gizp, I tested some Gzip Function on Nokia 6030, Nokia 6070 and more one, it show blank page or some time keep reloading if enable Gzip function, Am talking about XHTML version not WML:D
            Sutta kam mara kar oye, khatam hojayga hahahahaha......, I got a function for Gzip its realy nice but I fixed it for some sets wich not support GZIP. so even if you test them than they show GZIP n Deflate. I want for all sets support, is there any possiblity .think.

            Comment


              #7
              I had found another method of doin it that i think a lot better then this

              Comment


                #8
                you can have a look at http://chat-zone.mobi

                gzip works fine there

                Comment


                  #9
                  Add the following into your .htaccess file:

                  <IfModule mod_gzip.c>
                  mod_gzip_on Yes
                  mod_gzip_static_suffix .gz
                  AddEncoding gzip .gz
                  # Save temporary work files [Yes, No]
                  mod_gzip_keep_workfiles No
                  mod_gzip_maximum_file_size 500000
                  mod_gzip_maximum_inmem_size 60000
                  mod_gzip_handle_methods GET POST
                  ###############
                  ### filters ###
                  ###############
                  mod_gzip_item_exclude reqheader "User-agent: Mozilla/4.0[678]"
                  # HTML, CGI scripts, PHP
                  mod_gzip_item_include file \.html$
                  mod_gzip_item_include file \.php$
                  mod_gzip_item_include file \.pl$
                  mod_gzip_item_include mime ^text/html$
                  mod_gzip_item_include mime ^text/plain$
                  mod_gzip_item_include mime ^httpd/unix-directory$

                  # DO NOT DO JavaScript & CSS (due to Netscape4 bugs)
                  mod_gzip_item_exclude file \.js$
                  mod_gzip_item_exclude file \.css$
                  mod_gzip_item_exclude mime ^image/

                  mod_gzip_dechunk Yes
                  mod_gzip_add_header_count Yes
                  mod_gzip_send_vary On
                  </IfModule>

                  by VirusDoctor(webmaster-talk.com)
                  sigpic

                  Comment


                    #10
                    yeah it doesnt seem to work so great with All mobiles
                    Due to slow signals it can cause problems like constant refreshing

                    Comment


                      #11
                      I've got some complaints from users with old mobile phones about that issue (constant refreshing) in the past... Unaware of it, I was already using Gzip at that time.

                      Can Gzip be the major problem? Or it simple happens in heavy pages with lot's of CSS?

                      PS: I had to register here again, as I could not login with my old username. Bah!

                      Comment


                        #12
                        I use gzip for xhtml sites not for wml because possible problems with some old phones.
                        Advertise your mobile site for FREE with AdTwirl

                        Comment


                          #13
                          yeah I think it because of the slow signal...... when i use my laptop with mobile usb in a 2g zone it does the same thing..... page refreshes over and over.

                          Comment

                          Working...
                          X