What's the latest on (session like) saving data between page loads?
-
Hi all,
Very new to anything like this in WordPress. Perhaps I’m going about this the wrong way but I’d like to cache some request data to tone down network requests by caching the data.
In typical PHP you could use a good old fashioned $_SESSION, or I’d just use JavaScript myself and write it to localStorage. Since I see relatively very little out there in regards to using $_SESSION with WordPress it just feels like I may be overlooking an API on the WP side.
I do see sessions.php for user metadata but it seems to be more oriented toward expanding registered user data.
The data that I’m trying to cache is page content that has nothing to do with the current using pulling it. It’s 100% public, content from a remote site.
As best I can figure, if I use WP’s REST API to pull the data (in a plugin), save the request with an expiring timestamp in a table local to the WP site then I can pull that data for every request without hitting the API. Once the timestamp is exceeded I’d re-pull the data and update it.
Is this nature outside of anything WP-friendly? Is there another class or path I should be considering for this? I’d like to keep the data pull server-side in PHP for this.
Thanks for tips!
- The topic ‘What's the latest on (session like) saving data between page loads?’ is closed to new replies.