Google cache api - кеширование URL с параметрами get - PullRequest
0 голосов
/ 01 апреля 2019

Я пытаюсь кэшировать страницы моего веб-приложения J2EE.Мне удается кешировать страницы без каких-либо параметров.Но для страниц с параметрами GET, добавленными в конце URL, я не могу этого сделать.

Может кто-нибудь подсказать мне, как я могу кэшировать веб-страницу с параметрами get?

Ниже приведен мой код:

const cacheName = 'sailors-cache';

const domainurl = '/The_Sailors_Application/Application/';

const cacheAssets = [
    domainurl + 'images/logo.png',
    domainurl + 'report-surveyor-generalinfo.html',
    domainurl + 'report-surveyor-timelog.html',
    domainurl + 'report-surveyor-acknowledgement.html',
    domainurl + 'report-surveyor-barge.html',
    domainurl + 'report-surveyor-bunker-condition.html',
    domainurl + 'report-surveyor-bunker-condition2.html',
    domainurl + 'report-surveyor-statement.html',
    domainurl + 'report-surveyor-sealchecklist.html',
    domainurl + 'report-surveyor-samplingreport.html',
    domainurl + 'report-surveyor-vessel-measurement-report.html',
    domainurl + 'report-surveyor-finalreport.html',
    domainurl + 'report-surveyor-mass-flow-meter.html',
    domainurl + 'report-surveyor-cargo.html',
    domainurl + 'report-surveyor-checklist.html',
    domainurl + 'report-surveyor-feedback.html',
    domainurl + 'report-pictures.html',
    domainurl + 'signature.html',

    domainurl + 'assets/css/bootstrap.min.css',
    domainurl + 'assets/css/normalize.css',
    domainurl + 'assets/css/font-awesome.min.css',
    domainurl + 'assets/css/themify-icons.css',
    domainurl + 'assets/scss/style.css',

    domainurl + 'assets/js/vendor/jquery-2.1.4.min.js',
    domainurl + 'assets/js/plugins.js',
    domainurl + 'assets/js/widgets.js'
];

    // Call Install Event
    self.addEventListener('install', e => {
      console.log('Service Worker: Installed');

      e.waitUntil(
        caches
          .open(cacheName)
          .then(cache => {
            console.log('Service Worker: Caching Files');
            cache.addAll(cacheAssets);
          })
          .then(() => self.skipWaiting())
      );
    });

    // Call Activate Event
    self.addEventListener('activate', e => {
      console.log('Service Worker: Activated');
      // Remove unwanted caches
      e.waitUntil(
        caches.keys().then(cacheNames => {
          return Promise.all(
            cacheNames.map(cache => {
              if (cache !== cacheName) {
                console.log('Service Worker: Clearing Old Cache');
                return caches.delete(cache);
              }
            })
          );
        })
      );
    });

    // Call Fetch Event
    self.addEventListener('fetch', e => {
      console.log('Service Worker: Fetching');
      e.respondWith(fetch(e.request).catch(() => caches.match(e.request)));
    });

Пример веб-страницы URL, которую я хочу кэшировать, выглядит следующим образом: domainurl + 'report-surveyor-generalinfo.html? ReferenceNumber = YF-1223-19',

Спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...