You are here

function pwa_flush_caches in Progressive Web App 7

Implements hook_flush_caches().

2 calls to pwa_flush_caches()
pwa_admin_configuration_submit in ./pwa.admin.inc
Helper function to refresh Service Worker once admin settings are saved.
pwa_install in ./pwa.install
Implements hook_install().

File

./pwa.module, line 303

Code

function pwa_flush_caches() {
  $scheme = file_default_scheme();
  $directory = $scheme . '://pwa';
  file_prepare_directory($directory, FILE_CREATE_DIRECTORY);

  // Create the static manifest file with all the data.
  $manifest = _pwa_manifest_file();
  $manifest_uri = file_unmanaged_save_data($manifest, $directory . '/manifest.json', FILE_EXISTS_REPLACE);
  $manifest_url = file_create_url($manifest_uri);
  variable_set('pwa_filecache_manifest', str_replace($GLOBALS['base_url'] . '/', base_path(), $manifest_url));

  // Create the serviceworker file in cache so it can be served from a menu
  // callback so additional headers can be sent with the file.
  // @see pwa_deliver_js_file().
  cache_set('pwa:serviceworker', _pwa_serviceworker_file(), 'cache');
}