WordPress.org

Ready to get started?Download WordPress

Forums

WP-Piwik
[resolved] API call caching (3 posts)

  1. blau
    Member
    Posted 10 months ago #

    I have a LAMP server with several WP sites (not MU). In the first site wp-piwik works well, with Tracking>Enable cache: active in the plugin config options.

    In the second site enabling API cache breaks wp-piwik with a generic error (check auth token, URL and settings). this is the debug script output:

    *** Test 1/2: SitesManager.getSitesWithAtLeastViewAccess ***
    Using: cURL
    SSL peer verification: enabled
    User Agent:
    Call: https://piwik.mauta.org/?module=API&method=SitesManager.getSitesWithAtLeastViewAccess&format=XML&token_auth= + TOKEN
    Result:
    HTTP/1.1 200 OK
    Date: Fri, 20 Sep 2013 14:56:36 GMT
    Server: Apache/2.2.22 (Debian)
    X-Powered-By: PHP/5.4.4-14+deb7u4
    Set-Cookie: PIWIK_SESSID=i02mvdiffe79d1cr6dildor3l4; path=/; secure; HttpOnly
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache
    Vary: Accept-Encoding
    Content-Length: 2660
    Content-Type: text/xml; charset=utf-8
    
    <?xml version="1.0" encoding="utf-8" ?>
    <result>
    	<row>
    		<idsite>1</idsite>
    		<name>monsterlippa</name>
    		<main_url>http://monsterlippa.info</main_url>
    		<ts_created>2013-09-05 13:48:17</ts_created>
    		<ecommerce>0</ecommerce>
    		<sitesearch>1</sitesearch>
    		<sitesearch_keyword_parameters />
    		<sitesearch_category_parameters />
    		<timezone>Europe/Rome</timezone>
    		<currency>USD</currency>
    		<excluded_ips />
    		<excluded_parameters />
    		<excluded_user_agents />
    		<group />
    		<keep_url_fragment>0</keep_url_fragment>
    	</row>
    	<row>
    		<idsite>4</idsite>
    		<name>Nazione Indiana</name>
    		<main_url>http://www.nazioneindiana.com</main_url>
    		<ts_created>2013-09-19 13:26:07</ts_created>
    		<ecommerce>0</ecommerce>
    		<sitesearch>1</sitesearch>
    		<sitesearch_keyword_parameters />
    		<sitesearch_category_parameters />
    		<timezone>Europe/Rome</timezone>
    		<currency>EUR</currency>
    		<excluded_ips />
    		<excluded_parameters />
    		<excluded_user_agents />
    		<group />
    		<keep_url_fragment>0</keep_url_fragment>
    	</row>
    	<row>
    		<idsite>5</idsite>
    		<name>Carmilla online</name>
    		<main_url>http://carmillaonline.com</main_url>
    		<ts_created>2013-09-20 14:17:01</ts_created>
    		<ecommerce>0</ecommerce>
    		<sitesearch>1</sitesearch>
    		<sitesearch_keyword_parameters>q,query,s,search,searchword,k,keyword</sitesearch_keyword_parameters>
    		<sitesearch_category_parameters />
    		<timezone>Europe/Rome</timezone>
    		<currency>EUR</currency>
    		<excluded_ips />
    		<excluded_parameters />
    		<excluded_user_agents />
    		<group />
    		<keep_url_fragment>0</keep_url_fragment>
    	</row>
    	<row>
    		<idsite>6</idsite>
    		<name>The FK experience</name>
    		<main_url>http://markelo.net</main_url>
    		<ts_created>2013-09-20 14:25:51</ts_created>
    		<ecommerce>0</ecommerce>
    		<sitesearch>1</sitesearch>
    		<sitesearch_keyword_parameters>q,query,s,search,searchword,k,keyword</sitesearch_keyword_parameters>
    		<sitesearch_category_parameters />
    		<timezone>Europe/Rome</timezone>
    		<currency>EUR</currency>
    		<excluded_ips />
    		<excluded_parameters />
    		<excluded_user_agents />
    		<group />
    		<keep_url_fragment>0</keep_url_fragment>
    	</row>
    	<row>
    		<idsite>7</idsite>
    		<name>Hortus Conclusus</name>
    		<main_url>http://hortusconclusus.it</main_url>
    		<ts_created>2013-09-20 14:29:35</ts_created>
    		<ecommerce>0</ecommerce>
    		<sitesearch>1</sitesearch>
    		<sitesearch_keyword_parameters>q,query,s,search,searchword,k,keyword</sitesearch_keyword_parameters>
    		<sitesearch_category_parameters />
    		<timezone>Europe/Rome</timezone>
    		<currency>EUR</currency>
    		<excluded_ips />
    		<excluded_parameters />
    		<excluded_user_agents />
    		<group />
    		<keep_url_fragment>0</keep_url_fragment>
    	</row>
    </result>
    Time: 0.06s
    
    *** Test 2/2: SitesManager.getSitesIdFromSiteUrl ***
    Using: cURL
    SSL peer verification: enabled
    User Agent:
    Call: https://piwik.mauta.org/?module=API&method=SitesManager.getSitesIdFromSiteUrl&url=http%3A%2F%2Fwww.nazioneindiana.com&format=XML&token_auth= + TOKEN
    Result:
    HTTP/1.1 200 OK
    Date: Fri, 20 Sep 2013 14:56:36 GMT
    Server: Apache/2.2.22 (Debian)
    X-Powered-By: PHP/5.4.4-14+deb7u4
    Set-Cookie: PIWIK_SESSID=nv8911ac60040soeq2g59naq11; path=/; secure; HttpOnly
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache
    Vary: Accept-Encoding
    Content-Length: 94
    Content-Type: text/xml; charset=utf-8
    
    <?xml version="1.0" encoding="utf-8" ?>
    <result>
    	<row>
    		<idsite>4</idsite>
    	</row>
    </result>
    Time: 0.05s

    If I disable API call caching wp-piwik works as expected, here the script output:

    *** Test 1/2: SitesManager.getSitesWithAtLeastViewAccess ***
    Using: cURL
    SSL peer verification: enabled
    User Agent:
    Call: https://piwik.mauta.org/?module=API&method=SitesManager.getSitesWithAtLeastViewAccess&format=XML&token_auth= + TOKEN
    Result:
    HTTP/1.1 200 OK
    Date: Fri, 20 Sep 2013 14:57:18 GMT
    Server: Apache/2.2.22 (Debian)
    X-Powered-By: PHP/5.4.4-14+deb7u4
    Set-Cookie: PIWIK_SESSID=58vpsot9qsv2vq34bl8pp1dld2; path=/; secure; HttpOnly
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache
    Vary: Accept-Encoding
    Content-Length: 2660
    Content-Type: text/xml; charset=utf-8
    
    <?xml version="1.0" encoding="utf-8" ?>
    <result>
    	<row>
    		<idsite>1</idsite>
    		<name>monsterlippa</name>
    		<main_url>http://monsterlippa.info</main_url>
    		<ts_created>2013-09-05 13:48:17</ts_created>
    		<ecommerce>0</ecommerce>
    		<sitesearch>1</sitesearch>
    		<sitesearch_keyword_parameters />
    		<sitesearch_category_parameters />
    		<timezone>Europe/Rome</timezone>
    		<currency>USD</currency>
    		<excluded_ips />
    		<excluded_parameters />
    		<excluded_user_agents />
    		<group />
    		<keep_url_fragment>0</keep_url_fragment>
    	</row>
    	<row>
    		<idsite>4</idsite>
    		<name>Nazione Indiana</name>
    		<main_url>http://www.nazioneindiana.com</main_url>
    		<ts_created>2013-09-19 13:26:07</ts_created>
    		<ecommerce>0</ecommerce>
    		<sitesearch>1</sitesearch>
    		<sitesearch_keyword_parameters />
    		<sitesearch_category_parameters />
    		<timezone>Europe/Rome</timezone>
    		<currency>EUR</currency>
    		<excluded_ips />
    		<excluded_parameters />
    		<excluded_user_agents />
    		<group />
    		<keep_url_fragment>0</keep_url_fragment>
    	</row>
    	<row>
    		<idsite>5</idsite>
    		<name>Carmilla online</name>
    		<main_url>http://carmillaonline.com</main_url>
    		<ts_created>2013-09-20 14:17:01</ts_created>
    		<ecommerce>0</ecommerce>
    		<sitesearch>1</sitesearch>
    		<sitesearch_keyword_parameters>q,query,s,search,searchword,k,keyword</sitesearch_keyword_parameters>
    		<sitesearch_category_parameters />
    		<timezone>Europe/Rome</timezone>
    		<currency>EUR</currency>
    		<excluded_ips />
    		<excluded_parameters />
    		<excluded_user_agents />
    		<group />
    		<keep_url_fragment>0</keep_url_fragment>
    	</row>
    	<row>
    		<idsite>6</idsite>
    		<name>The FK experience</name>
    		<main_url>http://markelo.net</main_url>
    		<ts_created>2013-09-20 14:25:51</ts_created>
    		<ecommerce>0</ecommerce>
    		<sitesearch>1</sitesearch>
    		<sitesearch_keyword_parameters>q,query,s,search,searchword,k,keyword</sitesearch_keyword_parameters>
    		<sitesearch_category_parameters />
    		<timezone>Europe/Rome</timezone>
    		<currency>EUR</currency>
    		<excluded_ips />
    		<excluded_parameters />
    		<excluded_user_agents />
    		<group />
    		<keep_url_fragment>0</keep_url_fragment>
    	</row>
    	<row>
    		<idsite>7</idsite>
    		<name>Hortus Conclusus</name>
    		<main_url>http://hortusconclusus.it</main_url>
    		<ts_created>2013-09-20 14:29:35</ts_created>
    		<ecommerce>0</ecommerce>
    		<sitesearch>1</sitesearch>
    		<sitesearch_keyword_parameters>q,query,s,search,searchword,k,keyword</sitesearch_keyword_parameters>
    		<sitesearch_category_parameters />
    		<timezone>Europe/Rome</timezone>
    		<currency>EUR</currency>
    		<excluded_ips />
    		<excluded_parameters />
    		<excluded_user_agents />
    		<group />
    		<keep_url_fragment>0</keep_url_fragment>
    	</row>
    </result>
    Time: 0.05s
    
    *** Test 2/2: SitesManager.getSitesIdFromSiteUrl ***
    Using: cURL
    SSL peer verification: enabled
    User Agent:
    Call: https://piwik.mauta.org/?module=API&method=SitesManager.getSitesIdFromSiteUrl&url=http%3A%2F%2Fwww.nazioneindiana.com&format=XML&token_auth= + TOKEN
    Result:
    HTTP/1.1 200 OK
    Date: Fri, 20 Sep 2013 14:57:18 GMT
    Server: Apache/2.2.22 (Debian)
    X-Powered-By: PHP/5.4.4-14+deb7u4
    Set-Cookie: PIWIK_SESSID=cf71870pgh0j7c0t8pqkp7vu53; path=/; secure; HttpOnly
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache
    Vary: Accept-Encoding
    Content-Length: 94
    Content-Type: text/xml; charset=utf-8
    
    <?xml version="1.0" encoding="utf-8" ?>
    <result>
    	<row>
    		<idsite>4</idsite>
    	</row>
    </result>
    Time: 0.03s

    Why?
    What is the performance cost of not caching the API call?

    http://wordpress.org/plugins/wp-piwik/

  2. braekling
    Member
    Plugin Author

    Posted 10 months ago #

    It just a bug regarding caching: If WP-Piwik is not configured, it caches the non-configured API call and won't work anymore. After disabling caching and triggering the API calls again, you should be able to re-enable caching without problems.

  3. blau
    Member
    Posted 10 months ago #

    Thank you André, it is exactly as you say. I tried again and it accepts the API call caching this time.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags