Send appropriate Vary header

Fixes an issue where the XHR response was sometimes
displayed when navigating back to a pushState
based history entry rather than the full page.
Fix layers initialization