WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
[resolved] How I got my W3TC working with minify & gzip (24 posts)

  1. frg
    Member
    Posted 2 years ago #

    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/

  2. frg
    Member
    Posted 2 years ago #

    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..

  3. frg
    Member
    Posted 2 years ago #

  4. frg
    Member
    Posted 2 years ago #

    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";
  5. harvest316
    Member
    Posted 2 years ago #

    martinlbb rocks!

  6. titush
    Member
    Posted 2 years ago #

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

    ...

  7. MegaZone
    Member
    Posted 2 years ago #

    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/

  8. frg
    Member
    Posted 2 years ago #

    @titusch: good point!

    i am about to test the next "full" version 0.9.2.2..
    let´s see ;-)

  9. frg
    Member
    Posted 2 years ago #

    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

  10. akira28
    Member
    Posted 2 years ago #

    It doesn't work for me :(
    Still minification problems :(

  11. Frederick Townes
    Member
    Plugin Author

    Posted 2 years ago #

    Please try the latest release of the plugin.

  12. Max
    Member
    Posted 2 years ago #

    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.

  13. scottdaris
    Member
    Posted 2 years ago #

    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.

  14. kienleong
    Member
    Posted 2 years ago #

    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.

  15. LucyRyder
    Member
    Posted 2 years ago #

    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!

  16. adamf
    Member
    Posted 2 years ago #

    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

  17. Nick Davis
    Member
    Posted 2 years ago #

    Hi adamf/LucyRyder, having exactly the same issue here, everything working fine (with CDN/Cloudflare, then today hit the same problems) just wanted to subscribe in case of any useful follow-up posts

    If I find a solution in the meantime I'll post it

  18. Nick Davis
    Member
    Posted 2 years ago #

    I've tried everything but in the end (for the moment at least) the only thing that fixed it, was not just deactivating but uninstalling and reinstalling W3 Total Cache

    Simple but seems to be OK for now (touch wood)

    Hope it helps someone

  19. adamf
    Member
    Posted 2 years ago #

    Hi Nickyboy,

    Thanks for your reply. Its a maddening issue. What did you do to unistall?

    Just delete the entire plugin or is there some special unistall procedure you did?

    Thanks.

    -Adam

  20. Nick Davis
    Member
    Posted 2 years ago #

    Hey Adam

    I just went to the Plugins menu, deactivated W3 Total Cache and then removed it, hope that makes sense? Let me know if not.

    I also uninstalled another W3 related plugin Admin Flush W3TC Cache, I don't know if that had any effect but just to mention it as it may help you

    I realise everyone's set up is different so what worked for me might not work for you but hope it's some help, I feel your frustration!

    Cheers

    Nick

  21. David Favor
    Member
    Posted 2 years ago #

    On Ubuntu-11.10...

    W3TC is still broken in 0.9.2.4 for WordPress 3.2.1 and 3.3-beta3 as follows.

    ./lib/W3/Plugin/TotalCacheAdmin.php has a call to test_rewrite_minify() which
    in turn references .../wp-content/w3tc/min/ as a cache directory.

    The function test_rewrite looks for the cached object 'w3tc_rewrite_test_%s',
    creating it if required.

    Problem appears to be in get_transient() because if I camp on the entire wordpress
    install using inotifywait looking for any file containing w3tc_rewrite_test, no file is
    ever created.

    Rerunning /etc/cron.daily/mlocate then 'locate w3tc_rewrite_test' shows no file
    containing this string exists anywhere.

    So it appears the problem is inside test_rewrite() or get_transient().

    Unsure what to do next.

    Better for the Developer to release a fix.

  22. David Favor
    Member
    Posted 2 years ago #

    Hum... Directly fetching $domain/wordpress/wp-content/w3tc/min/ gives...

    There are all sorts of deprecated functions and other warnings.

    First I'll clear all these up... including the deprecated functions access in WordPress (what's that all about?) and retest.

    Once setting WP_DEBUG=true returns clean (no messages) I'll start tracking this down again.

  23. theroundwell
    Member
    Posted 2 years ago #

    I'm having the same problem on W3TC 0.9.2.4 and WordPress 3.3. I'm not clear -- did the developer already incorporate the changes suggested by frg/martinlbb in a prior update (say, 0.9.2.2 or 0.9.2.3)?

  24. Anatta
    Member
    Posted 2 years ago #

    @David - Your post pointed me in the right direction. I too was getting the infuriating

    It appears Minify URL rewriting is not working.
    errors with 0.9.2.4 on a dev server.

    Turned out that I was using a self-signed SSL certificate which was causing the function test_rewrite to fail on line 5924 of ./lib/W3/Plugin/TotalCacheAdmin.php because w3_http_get($url) returned a wp_error object:

    object(WP_Error)#260 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(146) "SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed" } } ["error_data"]=> array(0) { } }

    To fix either install a proper SSL cert or replace line 5294 with : $result = true;

    It's not really a bug in w3tc, but would be nice to be able to disable these tests if we find that they are giving false negatives like in this case.

    Thanks Frederick for a great plugin. I know how much work is involved to maintain a plugin of this nature and truly appreciate your efforts.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic