Skip to content

Prefix cache names for PHP-registered caching strategies#147

Merged
westonruter merged 5 commits intomasterfrom
prefix/registered-route-cache-names
Apr 10, 2019
Merged

Prefix cache names for PHP-registered caching strategies#147
westonruter merged 5 commits intomasterfrom
prefix/registered-route-cache-names

Conversation

@westonruter
Copy link
Copy Markdown
Collaborator

Prevent collisions in caches for subdirectory installs.

Fixes #146.

Before:

image

After:

image

$script .= sprintf( "workbox.core.setCacheNameDetails( %s );\n", wp_service_worker_json_encode( $cache_name_details ) );

// Export the prefix as a constant since it is not accessible via workbox.core.cacheNames, unfortunately (yet).
$script .= sprintf( 'const WP_SERVICE_WORKER_CACHE_PREFIX = %s;', wp_service_worker_json_encode( $prefix ) );
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See GoogleChrome/workbox#1998 for an enhancement to Workbox to allow accessing the cache prefix.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And see fix in GoogleChrome/workbox#2001 which we can take advantage of once the next version of Workbox is released.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we merge #150 first then we can avoid adding this const.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Workbox 4.2.0 has been released with the prefix getter.

@westonruter westonruter added this to the 0.2 milestone Apr 2, 2019
Copy link
Copy Markdown
Collaborator

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! One question in a separate comment - if that's not the case, then consider this approved already.

Comment thread wp-includes/components/class-wp-service-worker-configuration-component.php Outdated
westonruter added a commit to ampproject/amp-wp that referenced this pull request Apr 3, 2019
…es-redux

* 'develop' of github.com:ampproject/amp-wp: (31 commits)
  Add tests for AMP integration with PWA plugin
  Ensure is_amp_endpoint() returns false for service worker requests
  Account for element attributes when determining if a parent is empty and can be removed
  Fix tests after always including Gutenberg
  Add check for argument type in add_google_fonts_caching; advise to update to PWA 0.2
  Align default-enabled service worker features with ABE SW
  Remove todo resolved by GoogleChromeLabs/pwa-wp#147
  Make AMP service worker opt-out instead of opt-in
  Add tests for amp-twitter in STAMP layer and changes to amp-brid-player
  Update allowed tags/attributes from spec in amphtml 1903262220080
  Use proper URL for content in image caching
  Gate AMP service worker functionality behind theme support flag
  Add updated Google Fonts runtime caching particularly if PWA integration not enabled
  Unpluralize AMP_Service_Workers; sync changes from #1519
  Add comments with links to amp-by-example code
  Update runtime pre-caching based on GoogleChromeLabs/pwa-wp#61
  Apply changes for GoogleChromeLabs/pwa-wp#59
  Limit runtime images cache to URLs in wp-content
  Allow query params on URLs for cached images
  Improve passing of registry object to register_runtime_precaches method
  ...
westonruter added a commit to ampproject/amp-wp that referenced this pull request Apr 5, 2019
…r-mode

* 'develop' of github.com:ampproject/amp-wp: (50 commits)
  Fix printing of PHP upgrade notice
  Fix PHP notice for undefined theme support arg for service_worker
  Remove admin pointer tests that fail in 1.1
  Discontinue showing theme support admin pointer in 1.1
  Add tests for AMP integration with PWA plugin
  Ensure is_amp_endpoint() returns false for service worker requests
  Account for element attributes when determining if a parent is empty and can be removed
  Fix tests after always including Gutenberg
  Add check for argument type in add_google_fonts_caching; advise to update to PWA 0.2
  Align default-enabled service worker features with ABE SW
  Remove todo resolved by GoogleChromeLabs/pwa-wp#147
  Make AMP service worker opt-out instead of opt-in
  Opt-in to amp-img-auto-sizes experiment when there are converted images
  Remove obsolete add_auto_width_to_figure from #1086
  Add test for sizes attribute being removed from converted img
  Improve aligncenter, alignwide, and alignfull in classic templates
  Rename method to adjust_twentynineteen_images
  Eliminate sizes from amp-img converted from img
  Ensure featured image gets responsive layout in Twenty Nineteen, as it is essentially alignwide
  Give responsive layout to alignwide/alignfull instead of intrinsic layout
  ...
@westonruter
Copy link
Copy Markdown
Collaborator Author

Depends on merging #150 which will allow this PR to improve how it gets the prefix.

…-route-cache-names

* 'master' of github.com:xwp/pwa-wp: (22 commits)
  Bump minimum required WordPress to 5.1 and tested WordPress to 5.2.
  Update description of adding service worker theme support.
  Install xmllint for Trusty
  Add composer install during Travis build
  Update Node to 8.15.1
  Eliminate use of precise
  Bump Requires PHP to 5.6
  Add PROJECT_SLUG=pwa for dev-lib
  Remove dead code for PHP 5.2
  Install wp-dev-lib via composer instead of npm
  Run build during Travis install; remove PHP<5.6; add PHP 7.3
  Upgrade workbox to 4.2.0
  Bump required PHP version to 5.6
  Add admin notice for when installing from source
  Eliminate composer install from npm install
  Remove obsolete workbox-upgrade script
  Add install_workbox Grunt command and run as part of build
  Remove workbox files from being version controlled
  Add typehint for WP_Service_Worker_Scripts class.
  Allow granular enabling of service worker integrations, load integration classes only as they are needed.
  ...
@westonruter westonruter merged commit a4bcf44 into master Apr 10, 2019
@westonruter westonruter deleted the prefix/registered-route-cache-names branch April 10, 2019 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants