Support » Plugin: WP Statistics » Making WP Statistics work with page cache

  • Resolved Adame Dahmani



    When enabling the “Use Cache plugin” option (resaving permalinks, and clearing the cache), WP Statistics adds the following code, which seems to be used to create the API endpoint to process the visit data:

    <script>var WP_Statistics_http = new XMLHttpRequest();'GET', 'https://domain.extk/wp-json/wp-statistics/v2/hit?_=xxx&_wpnonce=yyy&wp_statistics_hit_rest=yes&browser=Chrome&platform=Windows&version=10.0&referred=https://referer.ext/&ip=zzz.zzz.zzz.zzz&exclusion_match=yes&exclusion_reason=user role&ua=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36 Edg/88.0.705.74&track_all=1&timestamp=1614082764&current_page_type=home&current_page_id=0&search_query&page_uri=/&user_id=3', true);WP_Statistics_http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");WP_Statistics_http.send(null);</script>

    The issue with that, and since the code is not added dynamically after the page loads, the first visit will generate the IP address, and all following visits will reference the same IP, referrer, etc.

    Any way to Ajaxify the process? Otherwise, it won’t work with page caching unless the cache is flushed for each visitor, which defies the purpose of using the page cache in the first place.

    Thank you for your efforts!

Viewing 1 replies (of 1 total)
  • Plugin Author Mostafa Soufi



    That’s totally true, in this case, the static cache page should not be enabled.

    I’ve already created a task for myself to change the logic of the request and move out it on the ajax.


    • This reply was modified 6 months, 2 weeks ago by Mostafa Soufi.
Viewing 1 replies (of 1 total)
  • The topic ‘Making WP Statistics work with page cache’ is closed to new replies.