Wordpress Json API缓存

use*_*810 4 api wordpress json caching

通过使用json api插件将数据从站点提供给应用程序,我使用Wordpress作为iPhone应用程序的提要.然而它很慢,所以我试图找到一种缓存请求的方法.我还没有找到一个真正有效的解决方案/解释如何做得好,任何人都可以提供任何指导哦,如何/可以做到这一点?

非常感谢

Dip*_* KC 5

我建议使用wordpress transient API.例如.

 $transient_name = 'some_api_req_param1';
 $transient_value = get_transient($transient_name); 
 if( false !== $transient_value){
  echo $transient_value;
 }else{
  //$result = ...
  //fetch your data here
  //in the end save the data in the transient
  $expiration_time = 60*60*24*7;//in second 
  set_transient($transient_name,$result,$expiration_time);
}
Run Code Online (Sandbox Code Playgroud)