I have W3 Total Cache and Cache Compatibility ENABLED in plugin settings.
Hi,
Thank you for opening the thread, can you please the plugin’s XHR request parameters in Developer Tools > Network?
And make sure the request has the correct IP address, you can double-check it with your server access log as well.
Where can I find this Developer Tools > Network?
Here is the request, IP address is correct.
This problem happens not all the time, but some times with some visitors.
https://[DOMAIN.COM]/wp-json/wp-statistics/v2/hit?_=1645568902&_wpnonce=89159b9621&wp_statistics_hit_rest=yes&browser=Chrome&platform=Windows&version=6.3&referred=https%3A%2F%2F[DOMAIN.COM]%2Fwp-admin%2F&ip=[IP]&exclusion_match=yes&exclusion_reason=user%20role&ua=Mozilla%2F5.0+%28Windows+NT+6.3%3B+Win64%3B+x64%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F96.0.4664.110+Safari%2F537.36&track_all=1×tamp=1645550902¤t_page_type=home¤t_page_id=0&search_query&page_uri=/&user_id=1
Here is request from another browser, my IP is correct:
https://[DOMAIN.COM]/wp-json/wp-statistics/v2/hit?_=1645569276&_wpnonce=f43e209f5d&wp_statistics_hit_rest=yes&browser=Safari&platform=OS X&version=10.15.6&referred=https://[DOMAIN.COM]&ip=[IP]&exclusion_match=no&exclusion_reason&ua=Mozilla/5.0+(Macintosh;+Intel+Mac+OS+X+10_15_6)+AppleWebKit/605.1.15+(KHTML,+like+Gecko)+Version/14.0.3+Safari/605.1.15&track_all=1×tamp=1645551276¤t_page_type=home¤t_page_id=0&search_query&page_uri=/&user_id=0
Let me know, if you need more details.
Here is a line from my server log with wrong IP, IPs are real:
64.255.91.127 - - [22/Feb/2022:11:05:33 -0500] "GET /wp-json/wp-statistics/v2/hit?_=1645545494&_wpnonce=f43e209f5d&wp_statistics_hit_rest=yes&browser=Chrome&platform=OS%20X&version=10.15.7&referred=https%3A%2F%2Fduckduckgo.com%2F&ip=69.114.2.154&exclusion_match=no&exclusion_reason&ua=Mozilla%2F5.0+%28Macintosh%3B+Intel+Mac+OS+X+10_15_7%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F98.0.4758.102+Safari%2F537.36&track_all=1×tamp=1645527494¤t_page_type=post¤t_page_id=9338&search_query&page_uri=[PATH]/&user_id=0 HTTP/1.1" 200 85 "https://[DOMAIN.COM]/[PATH]/" "Mozilla/5.0 (X11; Fedora; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.105 Safari/537.36"
So, basically, request was made by IP 64.255.91.127, but it is 69.114.2.154 in request params.
Those two people visited website with around 7 minutes difference, first 69.114.2.154, then 64.255.91.127. There were no other visitors between them, but I have checked statistics in admin panel between those two visits with the following request:
/wp-json/wp-statistics/v2/metabox?name=quickstats&_=1645545587701
Do you use the static cache on your website? what’s the cache plugin name that is enabled on your WordPress?
I use W3 Total Cache plugin and “Cache Compatibility” is ENABLED in WP Statistics plugin settings.
I think the W3 Total Cache plugin caches all the visitor information that is appended to the page source inline by WP-Statistics, and this can be the main problem.
https://ibb.co/s6N3M1Q
Well, yes, there is no point doing XMLHttpRequest this way.
You need to get all the required params by using javascript, thus they won’t be cached.
Try once again by disabling the “Inline JS modification” option in W3 Total Cache
There is no modification, there is only minification.
And Minify->HTML&XML->Inline JS minification is already DISABLED.
Are there any relative options for “Page Cache Static”?
There are lots of page cache options.
You have inline JS like this:
<script>var WP_Statistics_http = new XMLHttpRequest();WP_Statistics_http.open('GET', 'https://[DOMAIN.COM]/wp-json/wp-statistics/v2/hit?_=1646003004&_wpnonce=865577ec67&wp_statistics_hit_rest=yes&browser=Safari&platform=OS X&version=10.15.6&referred=https%3A%2F%2F[DOMAIN.COM]&ip=[IP]&exclusion_match=no&exclusion_reason&ua=Mozilla%2F5.0+%28Macintosh%3B+Intel+Mac+OS+X+10_15_6%29+AppleWebKit%2F605.1.15+%28KHTML%2C+like+Gecko%29+Version%2F14.0.3+Safari%2F605.1.15&track_all=1×tamp=1645985004¤t_page_type=home¤t_page_id=0&search_query&page_uri=/&user_id=0', true);WP_Statistics_http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");WP_Statistics_http.send(null);</script>
This is wrong! Any cache plugin will cache that. You have to collect all those details dynamically and post with js.
You are doing it statically!
Any update on that?
I keep getting wrong IPs, WP-Statistics is definitely not compatible with cache plugins at the moment.
Thank you!