• FWIW – This is my forked version of the API, specifically customized to power laybabylay.com: https://github.com/chiplay/wp-json-api

    There are new models for custom post types / taxonomies, logic for some Advanced Custom Fields, more powerful search logic, some general bug fixes, caching, user auth, and more. Many of the piece are from other support post / forks – so thanks everybody! Hopefully this will be helpful starting place for those looking to create their own custom version.

    https://www.ads-software.com/plugins/json-api/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Nice one, I’m currently looking into tweaking it a bit aswell, more so about adding in caching, can I ask how you went about doing it?

    Having a look at it I can see you used the transient api?

    Thread Starter chiplay

    (@chiplay)

    I used this patch for transient caching – although it seems to leave rows in the db and probably needs some more work: https://www.ads-software.com/support/topic/patch-adding-caching-benchmarking-and-setting-change-notices

    Thread Starter chiplay

    (@chiplay)

    As a follow up – I just installed Transient Cleaner which seems to take care of the expired transient rows. The caching seems to be working correctly.

    Ah brilliant that’s great! I’ve been playing around with your copy and I can see you’ve a few additional things for custom fields and what not which I don’t have a need for.

    One thing I’m looking into is a way to store the cache until it has been purged.

    For example, our high volume news site needs to make sure the cache is cleared as soon as new content is published, but sometimes there could be several hours with no new news, so there’s no point in clearing the cache on an interval basis for this time.

    I know I could set a low interval for caching so the transients expiry quickly, but I’d prefer that they would only expire on a manual purge (or on a post publish event)

    I haven’t looked too hard just yet, but I’m sure there is a way to track these transients that are set and then purge them individually?

    Thread Starter chiplay

    (@chiplay)

    You might try a custom method that deletes all ‘_json_api’ transients when a new post is published – see https://wordpress.stackexchange.com/questions/144411/how-to-delete-a-transient-on-post-page-publish. Then you could set the expired value really high and you should be set. Hope that helps!

    Yes I think that’s what I’ll have to do alright, shouldn’t be too tricky, good to know I’m thinking in the right direction at least!

    However I’ve noticed another thing, I’m using the API for an app I’m building. When I have benchmarking enabled and I request the api from my browser I can see it’s serving a cached response.

    However when I request it from my app (via AJAX JSONP) I can see it’s not returning a cached response. No matter how many times I call the exact same request it returns a non cached version.

    I have a feeling it’s because it’s being requested via JSONP (to solve those pesky cross domain problems) but I’m not certain yet. Any ideas on that?

    Hmm I believe the reason is certainly because of the JSONP request. Because JSONP wraps the request in a function to get around the cross domain problems, the request url is slightly different everytime. So because it’s different I’m guessing that there is no transient to match it, hence a cached version is never shown.

    For example a standard browser $_SERVER['REQUEST_URI'] would look like
    ?json=1

    But when requesting from my app with JSONP it appears something like
    ?json=1&callback=jQuery19108552455483004451_1408920405423&_=1408920405424

    think I’ll have to do some string handling on the incoming request url to ignore everthing after the &callback and it should hopefully be ok!

    I’ll keep digging!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘JSON API Fork (Advanced Custom Fields, caching, more)’ is closed to new replies.