javascript - Google 缓存 api - 使用获取参数缓存 url
问题描述
我正在尝试缓存我的 J2EE Web 应用程序页面。我设法在没有任何参数的情况下缓存页面。但是对于在 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',
谢谢你。
解决方案
推荐阅读
- c# - 以普通文本格式导出 Excel
- c - 哪些组件使用语言环境变量?
- java - Websphere对象cahce实现不起作用
- php - 使用数组值作为新的多维数组键
- python - 在 SymPy 中从块矩阵构建矩阵
- monaco-editor - 如何向 Monaco 编辑器添加新的语言语法?
- apache-spark - 如何在 spark 1.6.3 中用 java 编写 spark 上下文,以便将文件转换为数据帧。
- java - 如何在 Spring MVC 4 中的 Servlet 中注入依赖项?
- c - Mongo C 客户端因错误而失去连接
- fastlane - 如何在 fastlane 中将内部版本号设置为管道 ID?