• Hi!

    I’ve found an error in nginx configuration generated by W3TC (v.094):

    if ($w3tc_rewrite = 1) {
    rewrite .* “/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_rewrite$w3tc_ext$w3tc_enc” last;

    Should be:

    if ($w3tc_rewrite = 1) {
    rewrite .* “/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ext$w3tc_enc” last;

    AND

    if (-f “$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_rewrite.html$w3tc_enc”) {

    Should be:

    if (-f “$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index.html$w3tc_enc”) {

    etc.

    Because there are no cache files like _index1.html and You’ll get error

    https://wordpress.org/plugins/w3-total-cache/

Viewing 1 replies (of 1 total)
  • The error is deeper. Please fix following lines in wp-content/plugins/w3-total-cache/lib/W3/PgCacheAdminEnvironment.php from beginning from line 960 (tested with version 0.9.4.1):

    /**
    * Check for preview cookie
    */
    $rules .= "if (\$http_cookie ~* \"(w3tc_preview)\") {\n";
    $rules .= " set \$w3tc_rewrite _preview;\n";
    $rules .= "}\n";
    $env_w3tc_preview = "\$w3tc_rewrite";

    It should be:

    /**
    * Check for preview cookie
    */
    $rules .= "if (\$http_cookie ~* \"(w3tc_preview)\") {\n";
    $rules .= " set \$w3tc_preview _preview;\n";
    $rules .= "}\n";
    $env_w3tc_preview = "\$w3tc_preview";

    They did a mistake by using w3tc_rewrite and not w3tc_preview. w3tc_rewrite is used in the generated nginx.conf in a different context, so it should be w3tc_preview. After the correction the generated nginx.conf works perfectly!

Viewing 1 replies (of 1 total)

The topic ‘Error in W3TC nginx config?’ is closed to new replies.