• Resolved kocakserdar7

    (@kocakserdar7)


    Hi,

    I installed W3 total cache with multisite (subdirectory) on Nginx server. And when I activate cache-control headers, it looks duplicated. Check the below img please:

    Ekran-Resmi-2018-10-31-14-45-33
    Ekran-Resmi-2018-10-31-14-46-04

    If I deactivate the W3TC, all of the cache-control headers are removed. How can I fix it?

    This is nginx.conf file for W3TC:

    # BEGIN W3TC Minify cache
    location ~ /wp-content/cache/minify/.*\.js$ {
        types {}
        default_type application/x-javascript;
        expires modified 31536000s;
        add_header X-Powered-By "W3 Total Cache/0.9.7";
        add_header Pragma "public";
        add_header Cache-Control "max-age=31536000, public";
    }
    location ~ /wp-content/cache/minify/.*\.css$ {
        types {}
        default_type text/css;
        expires modified 31536000s;
        add_header X-Powered-By "W3 Total Cache/0.9.7";
        add_header Pragma "public";
        add_header Cache-Control "max-age=31536000, public";
    }
    # END W3TC Minify cache
    # BEGIN W3TC Page Cache cache
    location ~ /wp-content/cache/page_enhanced.*html$ {
        expires modified 3600s;
        add_header X-Powered-By "W3 Total Cache/0.9.7";
        add_header Vary "Accept-Encoding, Cookie";
        add_header Pragma "public";
        add_header Cache-Control "max-age=3600, public";
    }
    # END W3TC Page Cache cache
    # BEGIN W3TC Browser Cache
    location ~ \.(css|htc|less|js|js2|js3|js4)$ {
        expires 31536000s;
        etag on;
        if_modified_since exact;
        add_header Pragma "public";
        add_header Cache-Control "max-age=31536000, public";
        add_header X-Powered-By "W3 Total Cache/0.9.7";
        try_files $uri $uri/ $uri.html /index.php?$args;
    }
    location ~ \.(html|htm|rtf|rtx|svg|txt|xsd|xsl|xml)$ {
        expires 3600s;
        etag on;
        if_modified_since exact;
        add_header Pragma "public";
        add_header Cache-Control "max-age=3600, public";
        add_header X-Powered-By "W3 Total Cache/0.9.7";
        try_files $uri $uri/ $uri.html /index.php?$args;
    }
    location ~ \.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|webp|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|_ttf|wav|wma|wri|woff|woff2|xla|xls|xlsx|xlt|xlw|zip)$ {
        expires 31536000s;
        etag on;
        if_modified_since exact;
        add_header Pragma "public";
        add_header Cache-Control "max-age=31536000, public";
        add_header X-Powered-By "W3 Total Cache/0.9.7";
        try_files $uri $uri/ $uri.html /index.php?$args;
    }
    location ~ \.(bmp|class|doc|docx|eot|exe|ico|webp|json|mdb|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|pot|pps|ppt|pptx|svg|svgz|swf|tif|tiff|ttf|ttc|_ttf|wav|wri|woff|woff2|xla|xls|xlsx|xlt|xlw)$ {
        etag off;
        if_modified_since off;
        try_files $uri $uri/ $uri.html /index.php?$args;
    }
    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header Referrer-Policy "";
    # END W3TC Browser Cache
    # BEGIN W3TC Minify core
    set $w3tc_enc "";
    if (-f $request_filename$w3tc_enc) {
        rewrite (.*) $1$w3tc_enc break;
    }
    rewrite ^/([a-z0-9]+/)?wp-content/cache/minify/ /index.php last;
    # END W3TC Minify core
    # BEGIN W3TC Page Cache core
    set $w3tc_rewrite 1;
    if ($request_method = POST) {
        set $w3tc_rewrite 0;
    }
    if ($query_string != "") {
        set $w3tc_rewrite 0;
    }
    if ($request_uri !~ \/$) {
        set $w3tc_rewrite 0;
    }
    if ($http_cookie ~* "(comment_author|wp\-postpass|w3tc_logged_out|wptouch_switch_toggle)") {
        set $w3tc_rewrite 0;
    }
    if ($http_user_agent ~* "(W3\ Total\ Cache)") {
        set $w3tc_rewrite 0;
    }
    set $w3tc_preview "";
    if ($http_cookie ~* "(w3tc_preview)") {
        set $w3tc_preview _preview;
    }
    set $w3tc_ssl "";
    if ($scheme = https) {
        set $w3tc_ssl _ssl;
    }
    if ($http_x_forwarded_proto = 'https') {
        set $w3tc_ssl _ssl;
    }
    set $w3tc_ext "";
    if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ssl$w3tc_preview.html") {
        set $w3tc_ext .html;
    }
    if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ssl$w3tc_preview.xml") {
        set $w3tc_ext .xml;
    }
    if ($w3tc_ext = "") {
      set $w3tc_rewrite 0;
    }
    if ($w3tc_rewrite = 1) {
        rewrite .* "/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ssl$w3tc_preview$w3tc_ext" last;
    }
    # END W3TC Page Cache core
    

    Thank you,
    best regards.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @kocakserdar7,

    We only add one, you’ve added the header somewhere else too and that’s what is causing the problem.

    Thread Starter kocakserdar7

    (@kocakserdar7)

    @vmarko But If I deactivate W3TC or unselect its Browser cache feature, all of Cache-control headers are removed. How it is possible?

    Ekran-Resmi-2018-10-31-21-05-11

    and result:

    Ekran-Resmi-2018-10-31-21-06-55

    I think, It may be bug for multi-site. Because I have checked nginx.conf file. There is no cache-control rule there.

    • This reply was modified 6 years, 4 months ago by kocakserdar7.
    • This reply was modified 6 years, 4 months ago by kocakserdar7.
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @kocakserdar7,
    Have you enabled Cache-control header only in Performance>Browser Cache, General, or in any other sub-setting box?

    Thread Starter kocakserdar7

    (@kocakserdar7)

    Browser cache is activated. Also cache-control headers option is activated too. See below please:

    Ekran-Resmi-2018-10-31-22-49-51

    If I unselect ” set Cache control Header ” option on W3TC, the cache-control header looks like that:
    Ekran-Resmi-2018-10-31-22-54-57

    There is no ” public ” on the cache-control header. So It can create any issue?

    • This reply was modified 6 years, 4 months ago by kocakserdar7.
    Thread Starter kocakserdar7

    (@kocakserdar7)

    I think when we select ” set expires headers ” on W3TC, Nginx add ”cache-control” headers itself automatically (without ” public ”).

    So If we select ” Set expires header ” and ” Set cache control header ” both, then it creates duplicated cache-control issue.

    • This reply was modified 6 years, 4 months ago by kocakserdar7.
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @kocakserdar7,

    Thank you for providing this information.
    The “expires” directive in your nginx environment adds both Expires and Max-Age cache-control headers. That means you should enable “Expires” or “Cache-control” options, not both.
    We will disable cache-control options with Max-age contents in UI when Expires is checked in future releases.
    Once again thank you for bringing this to our attention,

    Thread Starter kocakserdar7

    (@kocakserdar7)

    You’re most welcome ??

    Best regards.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Please take some time and post a 5-star review here if convenient. This shouldn’t take more than a couple of minutes. Our goal is to continue offering a top-notch product, and your review could greatly help us to continue doing so.
    Best regards

    Thread Starter kocakserdar7

    (@kocakserdar7)

    Done ??

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Thank you very much!

    Hello, I am having exactly the same issue with duplicated max age issue?

    I am still not sure how this can be fixed??? I have disabled both checkbox and still see duplicate max age issue.

    Please advice.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello,
    If both boxes are unchecked then something else is causing that. Are you using any other caching plugin?

    Thread Starter kocakserdar7

    (@kocakserdar7)

    @lynnchin

    Don’t forget to run ” service nginx reload ”.

    Ah sorry looks like it is another issue. I will probably raise another card on this!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Duplicated Max-age issue’ is closed to new replies.