Title: API call caching
Last modified: August 21, 2016

---

# API call caching

 *  Resolved [blau](https://wordpress.org/support/users/blau/)
 * (@blau)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/api-call-caching/)
 * 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/](http://wordpress.org/plugins/wp-piwik/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [braekling](https://wordpress.org/support/users/braekling/)
 * (@braekling)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/api-call-caching/#post-4147225)
 * 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.
 *  Thread Starter [blau](https://wordpress.org/support/users/blau/)
 * (@blau)
 * [12 years, 7 months ago](https://wordpress.org/support/topic/api-call-caching/#post-4147230)
 * Thank you André, it is exactly as you say. I tried again and it accepts the API
   call caching this time.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘API call caching’ is closed to new replies.

 * ![](https://ps.w.org/wp-piwik/assets/icon-256x256.png?rev=3529668)
 * [Connect Matomo - Analytics Dashboard for WordPress](https://wordpress.org/plugins/wp-piwik/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-piwik/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-piwik/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-piwik/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-piwik/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-piwik/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [blau](https://wordpress.org/support/users/blau/)
 * Last activity: [12 years, 7 months ago](https://wordpress.org/support/topic/api-call-caching/#post-4147230)
 * Status: resolved