W3 Total Cache
Bug: Disk-enhanced caching on Nginx fails, due to a typo in the nginx.conf file (11 posts)

  1. Pothi Kalimuthu
    Posted 3 years ago #

    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.


  2. Eco Green Days
    Posted 3 years ago #

    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!

  3. Michael
    Forum Moderator
    Posted 3 years ago #

    @Eco Green Days

    please start your own topic.


  4. Keating
    Posted 3 years ago #

    Is this for only, not previous versions?

  5. Pothi Kalimuthu
    Posted 3 years ago #


    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.

  6. Frederick Townes
    Plugin Author

    Posted 3 years ago #

    Fixed in the next release.

  7. tarkin79
    Posted 3 years ago #

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

  8. Max
    Posted 3 years ago #

    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.

  9. Vince
    Posted 3 years ago #

    I can confirm that it has not been fixed in

  10. adamsadowski
    Posted 3 years ago #

    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.

  11. Pothi Kalimuthu
    Posted 3 years ago #

    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 .

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • W3 Total Cache
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic