Skip to content

Commit

Permalink
Amp-Wp-App-Shell - Improve flexibility for different types of caching
Browse files Browse the repository at this point in the history
Update amp-wp-app-shell.js

**Rationale**
Due to caching restrictions with WPengine the use of a query-string parameter to
denote an inner shell request is problematic as it prevents the request from
being cached independently. The request needs to be distinctly different from
the outer shell in-order for it to be treated as a seperate cache item.

**Changes**

- Query string parameter is now appended to the path instead of
- Fixed bug where code was always expecting a .site-branding element to exist
  • Loading branch information
mehigh committed Jan 22, 2020
1 parent 0c73fa3 commit 6054285
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion assets/js/amp-wp-app-shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
*/
function isHeaderVisible() {
const element = document.querySelector( '.site-branding' );
if ( ! element ) {
return;
}
const clientRect = element.getBoundingClientRect();
return clientRect.height + clientRect.top >= 0;
}
Expand All @@ -124,7 +127,8 @@
*/
function fetchShadowDocResponse( url ) {
const ampUrl = new URL( url );
ampUrl.searchParams.set( ampAppShell.componentQueryVar, 'inner' );
const pathSuffix = '_' + ampAppShell.componentQueryVar + '_inner';
ampUrl.pathname = ampUrl.pathname + pathSuffix;

return fetch( ampUrl.toString(), {
method: 'GET',
Expand Down

0 comments on commit 6054285

Please sign in to comment.