I've been searching around the web trying to find a better way to use WordPress transients with javascript. Currently I am using admin-Ajax to run a php function that retrieves the transient and returns it. This works fine but I'm curios to know if there is a more effective way of accessing that data without the overhead of using ajax and php.
I know I could probably do this using wp_localize_script()
but I'm not sure if that method is any better that my current solution. Hopefully there is an expert out there that can help me with this.
I've been searching around the web trying to find a better way to use WordPress transients with javascript. Currently I am using admin-Ajax to run a php function that retrieves the transient and returns it. This works fine but I'm curios to know if there is a more effective way of accessing that data without the overhead of using ajax and php.
I know I could probably do this using wp_localize_script()
but I'm not sure if that method is any better that my current solution. Hopefully there is an expert out there that can help me with this.
1 Answer
Reset to default 1Transients should be used for short (for varying definition of it) time caching, and they are by design not reliable. From your description it sound like you are using them in a manner they were not designed to support and therefor probably the "best" for you is to not use transients at all.
wp_localize_script()
(or any proper method to send the data within the document). – cybmeta Commented Dec 15, 2015 at 7:29