Cache settings build hash

Cyril's #2075 PR greatly increased the number of queries we do per page. Here, we cache it to a global variable to minimize the number of queries made.