(Issue #3715) cache margin calculation to avoid scaling all pages on new page load