Support » Plugin: W3 Total Cache » Bug: Disk-enhanced caching on Nginx fails, due to a typo in the nginx.conf file

  • W3 Total Cache version:
    WordPress version: 3.5.1
    Other plugins activated: none

    To reproduce what I meant in the subject header…

    – Deactivate all the modules in W3TC.
    – Activate disk-enhanced caching
    – Restart nginx
    – Visit the home page as a non-logged-in user.

    What is expected: The home page with ‘200’ as the header.
    What is occurring: The home page produces ‘404’

    What has gone wrong: A typo in the default configuration.

    A rewrite rule in the default configuration looks like this at the moment…

    if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index.html") {
      set $w3tc_rewrite 0;

    However, it should be…

    if (!-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index.html") {
      set $w3tc_rewrite 0;

    This is due the missing ‘!’ symbol at line number 923 of ‘lib/W3/Plugin/PgCacheAdmin.php’ file.

    I hope this helps someone who has had the same issue with the version of W3TC.

Viewing 10 replies - 1 through 10 (of 10 total)
  • I have same issue: i tried this code modification and not work! My WordPress is now broken, and is impossible to access on my dashboard!



    Forum Moderator

    @eco Green Days

    please start your own topic.

    Is this for only, not previous versions?


    I wish I had time to look into the previous versions as well. However, I’m sure that worked correctly on an Nginx server in disk-enhanced mode. I only tested the latest version at the time of testing, submitted a bug report, and then posted the solution here for the benefit of others who may need to wait until it is fixed.

    Plugin Author Frederick Townes


    Fixed in the next release.

    Still not fixed in the latest release. Pothi’s fix above has to be re-applied after upgrade.



    Yup, not fixed in

    uDiff of the fix, for those who want to repair this themselves.:

    --- PgCacheAdmin.php.old	2013-04-17 18:31:56.161238452 +0000
    +++ PgCacheAdmin.php	2013-04-17 18:32:30.065576141 +0000
    @@ -920,7 +920,7 @@
             if (!$this->_config->get_boolean('pgcache.cache.nginx_handle_xml')) {
                 $env_w3tc_ext = '.html';
    -            $rules .= "if (-f \"\$document_root" . $uri_prefix . ".html" .
    +            $rules .= "if (!-f \"\$document_root" . $uri_prefix . ".html" .
                     $env_w3tc_enc . "\") {\n";
                 $rules .= "  set \$w3tc_rewrite 0;\n";
                 $rules .= "}\n";

    Once you have applied the fix, you need to save the options in Page Cache in W3 Total Cache, then restart nginx, to reload the file that is generated.

    I can confirm that it has not been fixed in

    I think it is fixed in

    lib/W3/Plugin/PgCacheAdmin.php is still there, but doesn’t have that code anymore.

    I believe it is in lib/W3/PgCacheAdminEnvironment.php on line 1002, and it looks like it is fixed.

    Yes, I do think it’s fixed. I didn’t look at the code, though, since it’s been fixed.

    Thanks for the note @adamsadowski .

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Bug: Disk-enhanced caching on Nginx fails, due to a typo in the nginx.conf file’ is closed to new replies.