You are here

function hook_pwa_exclude_urls_alter in Progressive Web App 8

Same name and namespace in other branches
  1. 2.x pwa.api.php \hook_pwa_exclude_urls_alter()

Alters excluded urls list for the service worker file.

This hook allows adding or removing urls to the blacklist for the excluded urls. This is the same as the "URLs to cache on install" list on the service worker admin page.

After you make your modifications you do NOT need to return the results. Since $excludeUrls is passed by reference, any changes made to $excludeUrls are automatically registered.

Parameters

array &$excludeUrls: List of url to cache. Paths matching these patterns will not be cached by the Service Worker. Can be JavaScript regex.

\Drupal\Core\Cache\CacheableMetadata $cacheableMetadata: Cacheability metadata.

1 invocation of hook_pwa_exclude_urls_alter()
PWAController::pwa_serviceworker_file_data in src/Controller/PWAController.php
Replace the serviceworker file with variables from Drupal config.

File

./pwa.api.php, line 57
Hooks provided by the Progressive Web App module.

Code

function hook_pwa_exclude_urls_alter(&$excludeUrls, CacheableMetadata &$cacheableMetadata) {
  $excludeUrls[] = "path/pattern/.*";
  $excludeUrls[] = "just/path";
}