Preload not working
-
Hi! First of all, thanks for the amazing plugin.
Preloading isn’t working, event though there are no errors on the plugin and PHP logs nor the browser console. Purging working as expected.
Here is the plugin log:
https://share.cleanshot.com/xwlnhsNQAnd here is the plugin status tab:
https://share.cleanshot.com/xwlnhsNQWhat could I have missed?
One more question: does the plugin support custom post types?
Thank you again!
-
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
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/jxvprHrmAlso, 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/vgTlwlT4Thank you!
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
-
This reply was modified 7 months ago by
Hasan CALISIR.
-
This reply was modified 7 months ago by
Hasan CALISIR.
-
This reply was modified 7 months ago by
Hasan CALISIR.
@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/rFgwyCnX1. 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.
- Verify that the your NGINX cache directory is empty:
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
wgetprocess (used for preloading) has started and is running correctly:ps aux | grep wget- You should see one or more
wgetprocesses 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
wgetdoesn’t start or exits too early/prematurely let me know.
- You should see one or more
4. Verify Cache Generation
- Once
wgetis 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.
- Check the cache directory again:
5. Cross-Check Plugin Advanced Tab
- Return to the Advanced tab in NPP.
- If it does not display the cached content, despite
/opt/nginx-cachecontaining 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).
- If it does not display the cached content, despite
Best~Hasan
-
This reply was modified 7 months ago by
Hasan CALISIR.
-
This reply was modified 7 months ago by
Hasan CALISIR.
-
This reply was modified 7 months ago by
Hasan CALISIR.
-
This reply was modified 7 months ago by
Hasan CALISIR.
Hi @psauxit
I really appreciate your help on this!
If
wgetdoesn’t start or exits too early/prematurely let me know.wgetexited too early indeed. Besides, it seems it doesn’t start on every preload attempt. Here’s an example, where you can seewgetonly appeared on my third attempt:
https://share.cleanshot.com/JlcSlbLDEvent 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.You are welcome. We are close to find root issue.
First, let’s verify the arguments being passed to server
wgetcommand 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 breakingwgetIf 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.
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.Hi @psauxit,
The process died immediately. This is my wget version:
GNU Wget 1.21.3 built on linux-gnu.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_WEBSITEIf 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/tmpyet.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_WEBSITEPlease run both commands and let me know exactly what happens in each case.
-
This reply was modified 7 months ago by
Hasan CALISIR.
@psauxit All flags worked in conjunction, including the
-Pone. 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
nginxuser. And once again it didn’t work. To learn more I removed the--quietflag 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
rootandnginxdo).What else could be preventing the plugin from executing
wgetproperly?Thank you!
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-contentand editincludes/preload.phpto 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.
-
This reply was modified 7 months ago by
Hasan CALISIR.
-
This reply was modified 7 months ago by
Hasan CALISIR.
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!
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.comBest~Hasan
@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/PY9VwldcAs 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-userNginx webserver user:
$ grep -i '^\s*user\s\+' /etc/nginx/nginx.conf | grep -v '^\s*#' | awk '{print $2}' | sed 's/;.*//;s/\s*$//'
nginxPHP restrictions:
$ php -i | grep disable_functions
disable_functions => no value => no valueNginx Cache Path Permissions:
$ ls -ld /opt/nginx-cache
drwxr-xr-x. 18 nginx nginx 150 Jun 26 18:30 /opt/nginx-cachePHP 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/tmpOutbound HTTP (port 80) and HTTPS (port 443) permission:
https://share.cleanshot.com/Zw9VtZkY
Thank you!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
-
This reply was modified 7 months ago by
You must be logged in to reply to this topic.