Caching remote JSON with WordPress

March 21, 2016

Lately I worked on BetterOptin, the WordPress popup plugin that I develop with Julien Liabeuf. In the plugin's Dashboard, there is a documentation page which fetches a remote JSON and renders it. Should I use WordPress transients or HTML5 web storage to cache it?

Transients Pro & Cons:

  • Good control of expiration
  • Site-wide caching for all users

Web Storage Pro & Cons:

  • Easy to implement, especially with jQuery $.getJSON()
  • Caching per user → Result in higher server load
  • Nearly impossible to specify expiration. See John Resig's article about it.
  • The remote JSON needs CORS