Only get export meta data when needed

Hi all,

A while ago, lumen suggested a change to improve efficiency to page loads by reducing the number of calls to the database when a user hits a page, as discussed in this commit:

It was agreed that this particular change being suggested wasn’t a good long-term solution, and though caching does help for moderately sized books, in many of our cases, our users suffer long page loads because the database is being queried hundreds of times. Here was bracken’s comment that summarizes the problem:

“Even with caching this section could use an improvement to at least only do 1 call to the DB to get that meta field for all the relevant pages. As-is, it does a separate call for each page in the book, which in some of our cases is hundreds of extra calls for data that is only needed in one specific circumstance. So when there is an update, or this gets pushed out of the cache, some unlucky user is potentially waiting for a few seconds.”

I attempted connerbw’s fix, but I’m not sure I was implementing it correctly. Anyway, I wanted to ask the community here if anyone had any insight into how to approach and solve this problem.

Thanks in advance,

Bryan