WordPress.org

Support

Support » Plugins and Hacks » W3 Total Cache » [Resolved] [Plugin: W3 Total Cache] How I got my W3TC working with minify & gzip

[Resolved] [Plugin: W3 Total Cache] How I got my W3TC working with minify & gzip

  • it works!
    it works!

    How to correct Minify&Gzip-errors with W3Total Cache W3TC 0.9.2.1
    (based on M. Nieberg´s
    http://kenntwas.de/2011/tips/tools-allgemein/english-version-wordpress-get-w3tc-0-9-2-1-running-with-minify-and-gzip-compression/ )

    *** make backups of:
    
    wp-content/plugins/w3-total-cache/lib/Minify/Minify/Controller/Base.php
        wp-content/w3tc/min/.htaccess
        root/.htaccess
    *** edit wp-content/plugins/w3-total-cache/lib/Minify/Minify/Controller/Base.php
    
    change  ,'encodeMethod' => 'zero'
    to      ,'encodeMethod' => 'gzip'   //MN: Was 'zero', set to gzip
    *** set in admin Performance->Minify->General: Rewrite URL structure ON
    *** set in admin Performance->Browser Cache->Cascading Style Sheets & JavaScript: Enable HTTP (gzip) compression ON
     (this updates to your root/.htaccess)
    *** edit wp-content/w3tc/min/.htaccess:
    (in "W3TC Minify core" part)
    
    change  RewriteRule ^w3tc_rewrite_test$ index.php?w3tc_rewrite_test=1 [L]
    to      RewriteRule ^w3tc_rewrite_test$ index.php?w3tc_rewrite_test=1 [QSA,L]
    
    add     ReWriteCond %{REQUEST_FILENAME} !^.+\.gzip$
    after   RewriteCond %{HTTP:Accept-Encoding} gzip 
    
    change  RewriteRule (.*) $1%{ENV:APPEND_EXT} [L]
    to      RewriteRule (.*) $1%{ENV:APPEND_EXT} [QSA,L]
    
    change  RewriteRule (.*) index.php?file=$1 [L]
    to      RewriteRule (.*) index.php?file=$1 [QSA,L]
    *** edit root/.htaccess:
    
    remove a lot (60?) of linefeds which W3TC put.
    
    (in "W3TC Page Cache core" part)
    change  RewriteRule ^(.*\/)?w3tc_rewrite_test$ $1?w3tc_rewrite_test=1 [L]
    to      RewriteRule ^(.*\/)?w3tc_rewrite_test$ $1?w3tc_rewrite_test=1 [QSA,L]
    
    ("BLOGSUB/" is the name of your WP subdirectory, is missing if installed in root)
    change
    RewriteRule .* "/BLOGSUB/wp-content/w3tc/pgcache/%{REQUEST_URI}/_index%{ENV:W3TC_UA}%{ENV:W3TC_REF}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" [L]
    to
    RewriteRule .* "/BLOGSUB/wp-content/w3tc/pgcache/%{REQUEST_URI}/_index%{ENV:W3TC_UA}%{ENV:W3TC_REF}%{ENV:W3TC_SSL}.html%{ENV:W3TC_ENC}" [QSA,L]
    *** make both .htaccess files writeprotected by ftp:
    
    delete the write flags
    (doesnt work for me - i only get it down to 644 not 444)
    
    after i look in admin Performance, i got the two fleshy bars:
    Disk enhanced page caching is not active..auto install
    Minify is not active..auto install
    
    .. but i ignore them because my site works!
    
    minify & gzip is ok now!
    
    i know the changes will be overwritten if i change my W3TC settings again.

    http://wordpress.org/extend/plugins/w3-total-cache/

Viewing 15 replies - 1 through 15 (of 23 total)
  • ADDENDUM:

    for that your js scripts & css can be combined & minified steps in a certain order are appropriate:

    I.
    Performance->Browser Cache->Cascading Style Sheets & JavaScript: Enable HTTP (gzip) compression OFF
    all Minify Setting ON, of cause.

    II.
    put add your css and js under minify (minify manual in general settings)
    (allow updating .htaccess – you may lose changes you did for the FIX)
    test of the js loading order is correct & everything works on your site.
    combine js scripts & combine css.

    Check with http://webpagetest.org!

    your site should be optimized in W3TC by now as much as possible, just lacking proper gzip compression.

    III.
    the above FIX is to be applied last, when you dont want to touch W3TC settings any more..

    Addition by martinlbb (didnt try it yet [frg])

    BTW, to avoid auto erasing of modified settings in /wp-content/w3tc/min/.htaccess after each Minify update, you can modify following file:

    /wp-content/plugins/w3-total-cache/lib/W3/Plugin/Minify.php
    At lines 1076 and 1085 and 1088 add ‘QSA,’

    Before:

    $rules .= "    RewriteRule ^w3tc_rewrite_test$ index.php?w3tc_rewrite_test=1 [L]\n";
    
            if ($engine == 'file') {
                if ($compression) {
                    $rules .= "    RewriteCond %{HTTP:Accept-Encoding} gzip\n";
                    $rules .= "    RewriteRule .* - [E=APPEND_EXT:.gzip]\n";
                }
    
                $rules .= "    RewriteCond %{REQUEST_FILENAME}%{ENV:APPEND_EXT} -f\n";
                $rules .= "    RewriteRule (.*) $1%{ENV:APPEND_EXT} [L]\n";
            }
    
            $rules .= "    RewriteRule (.*) index.php?file=$1 [L]\n";

    After:

    $rules .= "    RewriteRule ^w3tc_rewrite_test$ index.php?w3tc_rewrite_test=1 [QSA,L]\n";
    
            if ($engine == 'file') {
                if ($compression) {
                    $rules .= "    RewriteCond %{HTTP:Accept-Encoding} gzip\n";
                    $rules .= "    RewriteRule .* - [E=APPEND_EXT:.gzip]\n";
                }
    
                $rules .= "    RewriteCond %{REQUEST_FILENAME}%{ENV:APPEND_EXT} -f\n";
                $rules .= "    RewriteRule (.*) $1%{ENV:APPEND_EXT} [QSA,L]\n";
            }
    
            $rules .= "    RewriteRule (.*) index.php?file=$1 [QSA,L]\n";

    martinlbb rocks!

    Are we going to to continue developing this plugin ourselves or does the author (maybe) want to release a bugfix?

    According to Twitter a bugfix is in testing. You can see there are recent development builds: http://plugins.trac.wordpress.org/log/w3-total-cache/

    @titusch: good point!

    i am about to test the next “full” version 0.9.2.2..
    let´s see 😉

    WP 3.1.3 + W3TC 0.9.2.2 just works flawless – i just gave it a test ride.

    http://foto.arcor-online.net/palb/alben/49/8355549/6264323639353066.jpg

    It doesn’t work for me 🙁
    Still minification problems 🙁

    Plugin Author Frederick Townes

    @fredericktownes

    Please try the latest release of the plugin.

    Hi Frederick,

    0.9.2.3 had no minify errors, now that I just upgraded to 0.9.2.4 I am suddenly seeing

    It appears Minify URL rewriting is not working. If using apache, verify that the server configuration allows .htaccess or if using nginx verify all configuration files are included in the configuration.

    Again.

    I don’t know if this applies, but see my post about automatic minifying errors:
    http://wordpress.org/support/topic/plugin-w3-total-cache-important-parsing-found-with-automatic-minify
    (btw, I meant to say *Important* parsing error found with automatic minify)
    In the minifying process, incorrect .js code was generated. You’ll see what I mean in my post. Good luck!

    To the developer: Thanks for your hard work in supplying this plugin to the WordPress world. However, there should be an option to protect existing settings (including .htaccess) when you disable/enable the plugin, as well as when you upgrade the plugin, which also messes up settings.

    I had the same problem with WP 3.2.1 and WPTC 0.9.2.4.

    Minify and Page cache errors as above. Here is how I fixed it.

    Changed the permission on .htaccess to 777.
    Re-saved WP3 total cache settings.
    Changed the permissions on .htaccess back to 644.

    LucyRyder

    @lucyryder

    Hello, I have just tried kienleog’s last post – but i cannot get it to work for me – whilst the .htaccess file is in 777 mode should the message
    It appears Minify URL rewriting is not working. If using apache, verify that the server configuration allows .htaccess or if using nginx verify all configuration files are included in the configuration.

    dissapear? – and then after it has gone you change the permission back to 644?

    Anyone else got it to work?

    Thanks!

    Everything was working great on my install, then I added a CDN and the Page Cache and Minify broke. The funny thing is, I can’t seem to go back. Even removing the CDN doesn’t seem to bring things back. Any ideas on what is causing this rewriting error for the Minify URL and Page Cache?

    I tried the change to 777, then resave and then back to 644 with no luck.

    -Adam

Viewing 15 replies - 1 through 15 (of 23 total)
  • The topic ‘[Resolved] [Plugin: W3 Total Cache] How I got my W3TC working with minify & gzip’ is closed to new replies.
Skip to toolbar