tl;dr: I want to load an XML file once and reuse it over and over again.
I have a bit of javascript that makes an ajax request to a PHP page that collects and parses some XML and returns it for display (like, say there are 4,000 nodes and the PHP paginates the results into chunks of 100 you would have 40 "pages" of data). If someone clicks on one of those other pages (besides the one that initially loads) then another request is made, the PHP loads that big XML file, grabs that subset of indexes (like records 200-299) and returns them for display. My question is, is there a way to load that XML file only once and just reuse it over and over?
The process on each ajax request is:
- load the xml file (simplexml_load_file())
- parse out the bits needed (with xpath)
- use LimitIterator to grab the specific set of indexes I need
- return that set
When what I'd like it to be when someone requests a different paginated result is:
- use LimitIterator on the data I loaded in the previous request (reparse if needed)
- return that set
It seems (it is, right?) that hitting the XML file every time is a huge waste. How would I go about grabbing it and persisting it so that different pagination requests don't have to reload the file every time?