<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi everyone,</p>
    <p>Just chasing up below, if anyone has any suggestions?</p>
    <p>So to recap, the situation is, I have nginx running Wordpress
      with the Hypercache plugin but only the homepage is cached, other
      pages "miss" according to page headers.</p>
    <p>Here is contents of the sites-enabled conf in question:<br>
    </p>
    <p><br>
    </p>
    <p><tt>server {</tt><tt><br>
      </tt><tt>        listen 80;</tt><tt><br>
      </tt><tt>        listen 443 ssl http2;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>        server_name NAMEOFSITECHANGED.COM;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>        ssl_certificate
        /etc/nginx/ssl/NAMEOFSITECHANGED.COM.crt;</tt><tt><br>
      </tt><tt>        ssl_certificate_key
        /etc/nginx/ssl/NAMEOFSITECHANGED.COM.key;</tt><tt><br>
      </tt><tt>        keepalive_timeout 70;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>        #enables all versions of TLS, but not SSLv2 or 3
        which are crap and now deprecated.</tt><tt><br>
      </tt><tt>        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>        #disable weak ciphers</tt><tt><br>
      </tt><tt>        ssl_ciphers
"ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";</tt><tt><br>
      </tt><tt>        ssl_prefer_server_ciphers on;</tt><tt><br>
      </tt><tt><br>
      </tt><tt><br>
      </tt><tt>        root /var/www/NAMEOFSITECHANGED.COM;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>        access_log
        /var/log/nginx/NAMEOFSITECHANGED.COM_access.log;</tt><tt><br>
      </tt><tt>        error_log
        /var/log/nginx/NAMEOFSITECHANGED.COM_error.log;</tt><tt><br>
      </tt><tt><br>
      </tt><tt><br>
      </tt><tt>        # don't cache anything using 'post' such as a
        form on subscribe page</tt><tt><br>
      </tt><tt>         if ($request_method = POST) { set $skip_cache 1;
        }</tt><tt><br>
      </tt><tt><br>
      </tt><tt>        # don't cache URLs containing the following
        elements</tt><tt><br>
      </tt><tt>        if ($request_uri ~*
        "/wp-admin/|wp-.*.php|index.php|preview=true") { set $skip_cache
        1; }</tt><tt><br>
      </tt><tt><br>
      </tt><tt>        # don't use the cache for logged in users</tt><tt><br>
      </tt><tt>        if ($http_cookie ~*
"comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|nCacheBypass")
        { set $skip_cache 1; }</tt><tt><br>
      </tt><tt><br>
      </tt><tt><br>
      </tt><tt>        #main</tt><tt><br>
      </tt><tt>        location / {</tt><tt><br>
      </tt><tt><br>
      </tt><tt>            index index.htm index.php;</tt><tt><br>
      </tt><tt>            try_files $uri $uri/ /index.php?$args;</tt><tt><br>
      </tt><tt>            error_page 404 = /404;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>            #handle old permalink URLs and rewrite</tt><tt><br>
      </tt><tt>            #rewrite ^/?video/(.*) /$1 permanent;</tt><tt><br>
      </tt><tt>        }</tt><tt><br>
      </tt><tt><br>
      </tt><tt><br>
      </tt><tt>        #pass the PHP scripts to FastCGI</tt><tt><br>
      </tt><tt>        location ~ \.php$ {</tt><tt><br>
      </tt><tt><br>
      </tt><tt>            include snippets/fastcgi-php.conf;</tt><tt><br>
      </tt><tt>            include fastcgi_params;</tt><tt><br>
      </tt><tt>           </tt><tt><br>
      </tt><tt>            fastcgi_pass unix:/run/php/php7.3-fpm.sock;</tt><tt><br>
      </tt><tt>            fastcgi_split_path_info ^(.+\.php)(/.+)$;</tt><tt><br>
      </tt><tt>            fastcgi_cache_bypass $skip_cache;</tt><tt><br>
      </tt><tt>            fastcgi_cache WORDPRESS;</tt><tt><br>
      </tt><tt>            fastcgi_cache_valid  60m;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>            error_page 404 = /404;</tt><tt><br>
      </tt><tt>        }</tt><tt><br>
      </tt><tt><br>
      </tt><tt><br>
      </tt><tt>        #no log on static files and expires header is set
        to maximum age</tt><tt><br>
      </tt><tt>        location ~*
^.+\.(css|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|js|gif|png|ico)$
        {</tt><tt><br>
      </tt><tt>            access_log off;</tt><tt><br>
      </tt><tt>            log_not_found off;</tt><tt><br>
      </tt><tt>            expires max;</tt><tt><br>
      </tt><tt>            add_header Pragma public;</tt><tt><br>
      </tt><tt>            add_header Cache-Control "public,
        must-revalidate, proxy-revalidate";</tt><tt><br>
      </tt><tt>       }</tt><tt><br>
      </tt><tt>}</tt><br>
      <br>
    </p>
    <p><br>
    </p>
    <p>And contents of /etc/nginx/nginx.conf:</p>
    <p><tt>user www-data;</tt><tt><br>
      </tt><tt>worker_processes auto;</tt><tt><br>
      </tt><tt>pid /run/nginx.pid;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>events {</tt><tt><br>
      </tt><tt>    worker_connections 8192;</tt><tt><br>
      </tt><tt>    # multi_accept on;</tt><tt><br>
      </tt><tt>}</tt><tt><br>
      </tt><tt><br>
      </tt><tt>http {</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    ##</tt><tt><br>
      </tt><tt>    # Basic Settings</tt><tt><br>
      </tt><tt>    ##</tt><tt><br>
      </tt><tt><br>
      </tt><tt>        #jore - extend times for SSL handshake etc to try
        keep server load low</tt><tt><br>
      </tt><tt>        ssl_session_cache   shared:SSL:10m;</tt><tt><br>
      </tt><tt>        ssl_session_timeout 10m;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    #jore - turn off server version and headers</tt><tt><br>
      </tt><tt>    server_tokens off;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    sendfile on;</tt><tt><br>
      </tt><tt>    tcp_nopush on;</tt><tt><br>
      </tt><tt>    tcp_nodelay on;</tt><tt><br>
      </tt><tt>    keepalive_timeout 65;</tt><tt><br>
      </tt><tt>    types_hash_max_size 2048;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    client_max_body_size 128M;</tt><tt><br>
      </tt><tt>    # server_tokens off;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    # server_names_hash_bucket_size 64;</tt><tt><br>
      </tt><tt>    # server_name_in_redirect off;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    include /etc/nginx/mime.types;</tt><tt><br>
      </tt><tt>    default_type application/octet-stream;</tt><tt><br>
      </tt><tt><br>
      </tt><tt><br>
      </tt><tt>    ##</tt><tt><br>
      </tt><tt>    # SSL Settings</tt><tt><br>
      </tt><tt>    ##</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping
        SSLv3, ref: POODLE</tt><tt><br>
      </tt><tt>    ssl_prefer_server_ciphers on;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    ##</tt><tt><br>
      </tt><tt>    # Logging Settings</tt><tt><br>
      </tt><tt>    ##</tt><tt><br>
      </tt><tt>    # Comment out to set individual site log locations in
        their own conf</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    #access_log /var/log/nginx/access.log;</tt><tt><br>
      </tt><tt>    #error_log /var/log/nginx/error.log;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    #jore - change the format of nginx http logs a little
        to suit awstats</tt><tt><br>
      </tt><tt>    log_format main     '$remote_addr - $remote_user
        [$time_local] "$request" '</tt><tt><br>
      </tt><tt>                        '$status $body_bytes_sent
        "$http_referer" '</tt><tt><br>
      </tt><tt>                        '"$http_user_agent"
        "$http_x_forwarded_for"';</tt><tt><br>
      </tt><tt><br>
      </tt><tt><br>
      </tt><tt>    ##</tt><tt><br>
      </tt><tt>    # Gzip Settings</tt><tt><br>
      </tt><tt>    ##</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    gzip on;</tt><tt><br>
      </tt><tt>    gzip_disable "msie6";</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    # gzip_vary on;</tt><tt><br>
      </tt><tt>    # gzip_proxied any;</tt><tt><br>
      </tt><tt>    # gzip_comp_level 6;</tt><tt><br>
      </tt><tt>    # gzip_buffers 16 8k;</tt><tt><br>
      </tt><tt>    # gzip_http_version 1.1;</tt><tt><br>
      </tt><tt>    # gzip_types text/plain text/css application/json
        application/javascript text/xml application/xml
        application/xml+rss text/javascript;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    ##</tt><tt><br>
      </tt><tt>    # Virtual Host Configs</tt><tt><br>
      </tt><tt>    ##</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    #jore - set up settings for memcached</tt><tt><br>
      </tt><tt>        fastcgi_cache_path /var/www/memcached levels=1:2
        keys_zone=WORDPRESS:100m inactive=1440m;</tt><tt><br>
      </tt><tt>        fastcgi_cache_key
        "$scheme$request_method$host$request_uri";  </tt><tt><br>
      </tt><tt>        fastcgi_cache_use_stale error timeout
        invalid_header http_500;</tt><tt><br>
      </tt><tt>        fastcgi_ignore_headers Cache-Control Expires
        Set-Cookie;</tt><tt><br>
      </tt><tt>        add_header X-Cached $upstream_cache_status;</tt><tt><br>
      </tt><tt><br>
      </tt><tt>    include /etc/nginx/conf.d/*.conf;</tt><tt><br>
      </tt><tt>    include /etc/nginx/sites-enabled/*;</tt><tt><br>
      </tt><tt>}</tt><br>
    </p>
    <p><br>
    </p>
    <p><br>
    </p>
    <p>/etc/nginx/conf.d is empty.</p>
    <p>Any ideas as to what I've messed up?</p>
    <p>Thanks!<br>
      Jore<br>
    </p>
    <p><br>
    </p>
    <p><br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 25/5/20 5:07 am, Jore wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:4b216683-84e5-cb74-9d03-cd48c0afe48b@thoughtmaybe.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p>Hi there,</p>
      <p>Thanks for that.</p>
      <p>Could you provide an example conf by any chance please, so I
        can get my head around that?</p>
      <p>Thanks!<br>
        Jore</p>
      <p><br>
      </p>
      <div class="moz-cite-prefix">On 24/5/20 8:56 am, Alex Evonosky
        wrote:<br>
      </div>
      <blockquote type="cite"
cite="mid:CAFZdCuo5xm5PVr-+MxLw6dNSSuULCCMeBUsqqz5bRAG3qxdhvA@mail.gmail.com">
        <meta http-equiv="content-type" content="text/html;
          charset=UTF-8">
        <div dir="ltr">Jore-
          <div><br>
          </div>
          <div>I applied the proxy_hide_header for no-cache headers to
            NGINX can process it and cache it.</div>
        </div>
        <br>
        <div class="gmail_quote">
          <div dir="ltr" class="gmail_attr">On Sat, May 23, 2020 at 5:17
            PM Jore <<a href="mailto:community@thoughtmaybe.com"
              moz-do-not-send="true">community@thoughtmaybe.com</a>>
            wrote:<br>
          </div>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">
            <div>
              <p>Hi Alex/all,</p>
              <p>How did you fix?</p>
              <p>I've got a very similar issue.</p>
              <p>nginx running Wordpress with the Hypercache plugin but
                only the homepage is cached, other pages "miss"
                according to page headers.</p>
              <p>Thanks,<br>
                Jore<br>
              </p>
              <p><br>
              </p>
              <div>On 24/5/20 7:04 am, Alex Evonosky wrote:<br>
              </div>
              <blockquote type="cite">
                <div dir="ltr">Disregard, found the issue.
                  <div><br>
                  </div>
                  <div>thank you.</div>
                </div>
                <br>
                <div class="gmail_quote">
                  <div dir="ltr" class="gmail_attr">On Sat, May 23, 2020
                    at 4:18 PM Alex Evonosky <<a
                      href="mailto:alex.evonosky@gmail.com"
                      target="_blank" moz-do-not-send="true">alex.evonosky@gmail.com</a>>
                    wrote:<br>
                  </div>
                  <blockquote class="gmail_quote" style="margin:0px 0px
                    0px 0.8ex;border-left:1px solid
                    rgb(204,204,204);padding-left:1ex">
                    <div dir="ltr">"Can you be more specific? Which
                      "cache"? Browser cache? Nginx content<br>
                      cache? try_files has nothing to do with
                      caching..."<br>
                      <br>
                      <br>
                      Nginx content cache<br>
                      <br>
                      <br>
                      "Either way, you need to check your headers to
                      ensure that they allow<br>
                      caching for said pages. Also if any cookies are
                      being sent then nginx<br>
                      won't cache the page."<br>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div>I looked at the headers using CURL..  </div>
                      <div><br>
                      </div>
                      <div>The issue seems this:</div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div>The request hits NGINX and the backend
                        server(s) for Wordpress are cached just fine
                        from just the FQDN --- <a
                          href="http://example.com" target="_blank"
                          moz-do-not-send="true">example.com</a></div>
                      <div><br>
                      </div>
                      <div>however, if I try to go to say, <a
                          href="http://example.com/?page_id=1234"
                          target="_blank" moz-do-not-send="true">example.com/?page_id=1234</a>,
                        the headers do not show NGINX anymore, as only
                        the servers for Wordpress show up; Almost like
                        a </div>
                      <div>cache punch-hole.</div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div>===== proxy.conf ====</div>
                      <div><br>
                      </div>
                      <div>proxy_cache_path /tmp/cache
                        keys_zone=my_cache:10m max_size=10m
                        inactive=60m;<br>
                        <br>
                        #proxy_redirect off;<br>
                        proxy_set_header Host $host;<br>
                        proxy_set_header X-Real-IP $remote_addr;<br>
                        proxy_set_header X-Forwarded-For
                        $proxy_add_x_forwarded_for;<br>
                        add_header X-Cache-Status
                        $upstream_cache_status;<br>
                        client_max_body_size 10m; <br>
                        client_body_buffer_size 128k;<br>
                        proxy_connect_timeout 90;<br>
                        proxy_send_timeout 90;<br>
                        proxy_read_timeout 90;<br>
                        proxy_buffers 32 4k;<br>
                      </div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div>==== nginx.conf ====</div>
                      <div><br>
                      </div>
                      <div>http {<br>
                                upstream <a href="http://example.com"
                          target="_blank" moz-do-not-send="true">example.com</a>
                        {<br>
                                least_conn;<br>
                                server <a
                          href="http://10.10.10.138:8999"
                          target="_blank" moz-do-not-send="true">10.10.10.138:8999</a>;<br>
                                server <a
                          href="http://10.10.10.84:8999" target="_blank"
                          moz-do-not-send="true">10.10.10.84:8999</a>;<br>
                                }<br>
                        <br>
                      </div>
                      <div>server {<br>
                        listen 82;<br>
                        location / {<br>
                        try_files $uri $uri/ /$args /index.php?$args;<br>
                        proxy_cache my_cache;<br>
                        proxy_cache_use_stale error timeout http_500
                        http_502 http_503 http_504;<br>
                        proxy_cache_background_update on;<br>
                        proxy_pass <a href="http://example.com"
                          target="_blank" moz-do-not-send="true">http://example.com</a>;<br>
                        proxy_cache_valid any 60m;<br>
                        proxy_cache_methods GET HEAD POST;<br>
                        proxy_http_version 1.1;<br>
                        proxy_set_header Connection keep-alive;<br>
                        proxy_ignore_headers Cache-Control Expires
                        Set-Cookie;<br>
                              }</div>
                      <div>}<br>
                        <br>
                        sendfile on;<br>
                        tcp_nopush on;<br>
                        tcp_nodelay on;<br>
                        keepalive_timeout 65;<br>
                        types_hash_max_size 2048;<br>
                        <br>
                        gzip on;<br>
                        gzip_disable "msie6";<br>
                        <br>
                        # include /etc/nginx/conf.d/*.conf;<br>
                        # include /etc/nginx/sites-enabled/*;<br>
                        include /etc/nginx/proxy.conf;<br>
                        <br>
                        }<br>
                      </div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div>Thank you,</div>
                      <div>Alex</div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                    </div>
                    <br>
                    <div class="gmail_quote">
                      <div dir="ltr" class="gmail_attr">On Sat, May 23,
                        2020 at 8:43 AM J.R. <<a
                          href="mailto:themadbeaker@gmail.com"
                          target="_blank" moz-do-not-send="true">themadbeaker@gmail.com</a>>
                        wrote:<br>
                      </div>
                      <blockquote class="gmail_quote" style="margin:0px
                        0px 0px 0.8ex;border-left:1px solid
                        rgb(204,204,204);padding-left:1ex">> And the
                        main page caches OK, but any page the resides on
                        the "?page_id" is<br>
                        > not getting cached.  Is there more to the
                        "try_files" that needs applied<br>
                        > for caching of these permalinks?<br>
                        <br>
                        Can you be more specific? Which "cache"? Browser
                        cache? Nginx content<br>
                        cache? try_files has nothing to do with
                        caching...<br>
                        <br>
                        Either way, you need to check your headers to
                        ensure that they allow<br>
                        caching for said pages. Also if any cookies are
                        being sent then nginx<br>
                        won't cache the page.<br>
                        _______________________________________________<br>
                        nginx mailing list<br>
                        <a href="mailto:nginx@nginx.org" target="_blank"
                          moz-do-not-send="true">nginx@nginx.org</a><br>
                        <a
                          href="http://mailman.nginx.org/mailman/listinfo/nginx"
                          rel="noreferrer" target="_blank"
                          moz-do-not-send="true">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
                      </blockquote>
                    </div>
                  </blockquote>
                </div>
                <br>
                <fieldset></fieldset>
                <pre>_______________________________________________
nginx mailing list
<a href="mailto:nginx@nginx.org" target="_blank" moz-do-not-send="true">nginx@nginx.org</a>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank" moz-do-not-send="true">http://mailman.nginx.org/mailman/listinfo/nginx</a></pre>
              </blockquote>
            </div>
            _______________________________________________<br>
            nginx mailing list<br>
            <a href="mailto:nginx@nginx.org" target="_blank"
              moz-do-not-send="true">nginx@nginx.org</a><br>
            <a href="http://mailman.nginx.org/mailman/listinfo/nginx"
              rel="noreferrer" target="_blank" moz-do-not-send="true">http://mailman.nginx.org/mailman/listinfo/nginx</a></blockquote>
        </div>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <pre class="moz-quote-pre" wrap="">_______________________________________________
nginx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:nginx@nginx.org" moz-do-not-send="true">nginx@nginx.org</a>
<a class="moz-txt-link-freetext" href="http://mailman.nginx.org/mailman/listinfo/nginx" moz-do-not-send="true">http://mailman.nginx.org/mailman/listinfo/nginx</a></pre>
      </blockquote>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
nginx mailing list
<a class="moz-txt-link-abbreviated" href="mailto:nginx@nginx.org">nginx@nginx.org</a>
<a class="moz-txt-link-freetext" href="http://mailman.nginx.org/mailman/listinfo/nginx">http://mailman.nginx.org/mailman/listinfo/nginx</a></pre>
    </blockquote>
  </body>
</html>