Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Hasan CALISIR

    (@psauxit)

    Hello @gabrielbonifacio

    First, clear the plugin cache on the Status tab, then start preloading the cache. Once preloading is complete, show me the Status tab and the Advanced tab.

    Also, are WordPress and Nginx running in separate containers, or on a monolithic server?

    Updated to v2.1.2?

    Best~Hasan

    • This reply was modified 7 months ago by Hasan CALISIR. Reason: version check
    Thread Starter gabrielbonifacio

    (@gabrielbonifacio)

    Hi @psauxit,

    First, clear the plugin cache on the Status tab, then start preloading the cache. Once preloading is complete, show me the Status tab and the Advanced tab.

    Done. Here is the Status tab:
    https://share.cleanshot.com/yj7tc2lK

    And the Advanced tab:
    https://share.cleanshot.com/jxvprHrm

    Also, are WordPress and Nginx running in separate containers, or on a monolithic server?

    They are on a monolithic server.

    Updated to v2.1.2?

    That’s right:
    https://share.cleanshot.com/vgTlwlT4

    Thank you!

    Plugin Author Hasan CALISIR

    (@psauxit)

    It seems your setup is ok and cache preloading is working.

    As I see in the Advanced tab, only your main page is cached via Preload. I’m not sure if this is a test WordPress setup with only homepage or a production website with pages, posts, CPTs.

    Add some dummy post, page and try preload cache again then check Advanced tab. You’ll be able to see them listed there. You can track in cache content on Advanced Tab always.

    If this is not the case, I mean you already have some post, pages -please go to your cache path /opt/nginx-cache on server manually and check integrity with Advanced Tab listing. If they are not in sync we can look other possible issues like regex pattern.

    Also check your permalinks settings on WordPress.

    Best~Hasan

    Thread Starter gabrielbonifacio

    (@gabrielbonifacio)

    @psauxit I’m afraid that’s not the case. The site has hundreds of pages and posts.

    Also check your permalinks settings on WordPress.

    The settings are pretty standard there:
    https://share.cleanshot.com/rFgwyCnX

    Plugin Author Hasan CALISIR

    (@psauxit)

    1. Initial Preparation

    • Login to WordPress Admin
      • Purge All cache first
    • Login to Server
      • Verify that the your NGINX cache directory is empty: ls -la /opt/nginx-cache
      • The directory should be empty if the Purge was successful. If not, let me know.

    2. Start Preloading

    • In the WordPress NPP dashboard, initiate the Cache Preloading now. Ensure the cache is Purged before initiating Preloading.

    3. Monitor Cache Preloading

    • On the server, immediately run the following command to check if the wget process (used for preloading) has started and is running correctly: ps aux | grep wget
      • You should see one or more wget processes actively running.
      • If your site has very little content (few posts or pages), the process may complete very quickly, making it easy to miss. If this is the case use watch -n 1 'ps aux | grep wget'
      • If wget doesn’t start or exits too early/prematurely let me know.

    4. Verify Cache Generation

    • Once wget is confirmed running and completes its task !!!
      • Check the cache directory again: ls -la /opt/nginx-cache
      • You should now see cache files being created, indicating that Cache Preloading has worked at the server level. If not, let me know.

    5. Cross-Check Plugin Advanced Tab

    • Return to the Advanced tab in NPP.
      • If it does not display the cached content, despite /opt/nginx-cache containing files, this may indicate a regex pattern issue in the plugin’s settings (used to parse URLs from cached files according to your _cache_key).

    Best~Hasan

    Thread Starter gabrielbonifacio

    (@gabrielbonifacio)

    Hi @psauxit

    I really appreciate your help on this!

    If wget doesn’t start or exits too early/prematurely let me know.

    wget exited too early indeed. Besides, it seems it doesn’t start on every preload attempt. Here’s an example, where you can see wget only appeared on my third attempt:
    https://share.cleanshot.com/JlcSlbLD

    Event then the cache folder remained empty. The site has 258 published posts and 91 pages.

    Also, it may be worth mentioning that I do see a couple of pages/posts on the Advanced page occasionally. But a page will only show there if I access it on the frontend first.

    Thank you again.

    Plugin Author Hasan CALISIR

    (@psauxit)

    You are welcome. We are close to find root issue.

    First, let’s verify the arguments being passed to server wget command from the front-end. In your plugin settings, click Reset Default for both Exclude Endpoints and Exclude File Extensions, then try again—this will rule out any custom entries that might be breaking wget

    https://ibb.co/xSzRBJyn

    If the issue persists, purge the cache first and run the replicated wget command generated by the NPP manually on the server by copying and pasting the exact command shown below. Don’t forget to change YOUR_WEBSITE at the end of the command.

    https://paste.rs/maePU

    If the process dies immediately, please let me know your wget version. If process completed successfully and cache content created at /opt/nginx-cache then let me check deeply for the issue.

    mail ~ # wget –version
    GNU Wget 1.25.0 built on linux-gnu.

    Thread Starter gabrielbonifacio

    (@gabrielbonifacio)

    Hi @psauxit,

    The process died immediately. This is my wget version:

    GNU Wget 1.21.3 built on linux-gnu.
    Plugin Author Hasan CALISIR

    (@psauxit)

    Ok.

    The following command will test whether your wget version supports all the basic flags required by NPP for Preloading. I dropped –reject-regex, –reject, –user-agent, -P flags to simplify things first. If this basic command not works then update your wget to latest.

    wget --quiet --recursive --no-cache --no-cookies --no-directories --delete-after --no-dns-cache --no-check-certificate --no-use-server-timestamps --no-if-modified-since --ignore-length --timeout=5 --tries=1 -e robots=off --limit-rate=5120k --wait=0 YOUR_WEBSITE

    If the above command works, start adding the remaining flags one by one --reject-regex, --reject, and --user-agent—from this full command, to identify if any of them causes issues. But not add -P /opt/nginx-cache/tmp yet.

    If everything goes fine the following one will test whether the nginx user can write to /opt/nginx-cache/tmp, helping us identify any potential permission issues.

    sudo -u nginx wget --quiet --recursive --no-cache --no-cookies --no-directories --delete-after --no-dns-cache --no-check-certificate --no-use-server-timestamps --no-if-modified-since --ignore-length --timeout=5 --tries=1 -e robots=off -P /opt/nginx-cache/tmp --limit-rate=5120k --wait=0 YOUR_WEBSITE

    Please run both commands and let me know exactly what happens in each case.

    Thread Starter gabrielbonifacio

    (@gabrielbonifacio)

    @psauxit All flags worked in conjunction, including the -P one. I found this weird, since the previous command you sent me didn’t work.

    So I repeated what I did back when it failed, which was running the full command without sudoing to the nginx user. And once again it didn’t work. To learn more I removed the --quiet flag and got this:

    HTTP request sent, awaiting response... 200 OK
    Length: ignored [text/html]
    /opt/nginx-cache/tmp/index.html.tmp: Bad file descriptor

    Cannot write to ‘/opt/nginx-cache/tmp/index.html.tmp’ (Bad file descriptor).

    So it looks like my first attempt didn’t work because the user didn’t have permissions to write on the cache folder (which is right, as only root and nginx do).

    What else could be preventing the plugin from executing wget properly?

    Thank you!

    Plugin Author Hasan CALISIR

    (@psauxit)

    According to your Status tab, both the PHP process owner and the webserver user are set to nginx. Initially, I did not suspect any permission issues, but there is still a slight possibility that permissions might be causing the problem. Therefore, we need to review the entire setup, including the PHP-FPM pool settings.

    Before that, the plugin has a built-in check for premature wget process termination that we should consider.

    Sorry for the deep dive, but you’ll need to edit the plugin code directly to perform this test; otherwise, I won’t be able to reproduce the issue.

    Please go to the plugin folder under wp-content and edit includes/preload.php to disable the premature wget process check part, simply comment out this code and this code part temporarily and re-check.

    After that we can focus permission issue.

    Thread Starter gabrielbonifacio

    (@gabrielbonifacio)

    HI @psauxit,

    I’ve commented out the lines as requested. I tried preloading once again, but no luck.

    I’ll be on the lookout for the next steps. Thank you!

    Plugin Author Hasan CALISIR

    (@psauxit)

    Hello @gabrielbonifacio

    Please use the this tiny PHP script to test NPP on your environment. Read Usage Instructions in script comments.

    Also, please share the results from your server.

    #Check PHP process owner

    ps -eo user:20,cmd | grep php-fpm | awk '$1 != "root" {print $1}'
    

    #Check Nginx webserver user

    grep -i '^\s*user\s\+' /etc/nginx/nginx.conf | grep -v '^\s*#' | awk '{print $2}' | sed 's/;.*//;s/\s*$//'
    

    #Check any PHP restrictions

    php -i | grep disable_functions
    

    #Check Nginx Cache Path Permissions

    ls -ld /opt/nginx-cache
    

    #Check if PHP process owner can write to cache path (first command returns nginx ?)

    sudo -u nginx mkdir -p /opt/nginx-cache/tmp
    sudo -u nginx bash -c 'echo "cache test" > /opt/nginx-cache/tmp/testfile.txt'
    ls -ld /opt/nginx-cache/tmp
    

    #Ensure outbound HTTP (port 80) and HTTPS (port 443) are allowed (better on panel)

    aws ec2 describe-security-groups --group-ids sg-xxxxxxx --query 'SecurityGroups[].IpPermissionsEgress'

    aws ec2 describe-network-acls --filters Name=vpc-id,Values=<your-vpc-id>
    curl -I https://www.google.com

    Best~Hasan

    Thread Starter gabrielbonifacio

    (@gabrielbonifacio)

    @psauxit Hello again. I can’t thank you enough for your kind assistance!

    Here is the test script output (I needed to blur some parts out for compliance reasons, sorry):
    https://share.cleanshot.com/LV8H5NBv
    https://share.cleanshot.com/PY9Vwldc

    As for the other tests:

    PHP process owner:

    $ ps -eo user:20,cmd | grep php-fpm | awk '$1 != "root" {print $1}'
    nginx
    nginx
    nginx
    nginx
    nginx
    nginx
    nginx
    nginx
    nginx
    nginx
    nginx
    nginx
    nginx
    nginx
    nginx
    nginx
    ec2-user

    Nginx webserver user:

    $ grep -i '^\s*user\s\+' /etc/nginx/nginx.conf | grep -v '^\s*#' | awk '{print $2}' | sed 's/;.*//;s/\s*$//'
    nginx

    PHP restrictions:

    $ php -i | grep disable_functions
    disable_functions => no value => no value

    Nginx Cache Path Permissions:

    $ ls -ld /opt/nginx-cache
    drwxr-xr-x. 18 nginx nginx 150 Jun 26 18:30 /opt/nginx-cache

    PHP process owner can write to cache path:

    $ sudo -u nginx mkdir -p /opt/nginx-cache/tmp
    $ sudo -u nginx bash -c 'echo "cache test" > /opt/nginx-cache/tmp/testfile.txt'
    $ ls -ld /opt/nginx-cache/tmp
    drwxr-xr-x. 2 nginx nginx 26 Jun 27 17:51 /opt/nginx-cache/tmp

    Outbound HTTP (port 80) and HTTPS (port 443) permission:
    https://share.cleanshot.com/Zw9VtZkY

    Thank you!

    Plugin Author Hasan CALISIR

    (@psauxit)

    Hey,

    Sorry for the late reply. I don’t like to say “please disable all plugins and try again,” but the issue might be related, so please try this as a last step. Unfortunately, I cannot reproduce the error you’re experiencing with the preload feature.

    If you find any clues, please share them so we can move forward.

    Best~Hasan

Viewing 15 replies - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.