caching layout queries