Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Churros
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Matteo Planchet
Churros
Commits
6c65e193
Commit
6c65e193
authored
Nov 11, 2023
by
Ewen Le Bihan
Browse files
Options
Downloads
Patches
Plain Diff
perf(service worker): make use of ASSETS cache
parent
e67a6954
Branches
Branches containing commit
Tags
v1.18.0
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/app/src/service-worker.ts
+6
-6
6 additions, 6 deletions
packages/app/src/service-worker.ts
with
6 additions
and
6 deletions
packages/app/src/service-worker.ts
+
6
−
6
View file @
6c65e193
...
...
@@ -113,15 +113,15 @@ sw.addEventListener('fetch', (event) => {
if
(
event
.
request
.
method
!==
'
GET
'
)
return
;
const
respond
=
async
()
=>
{
//
const url = new URL(event.request.url);
const
url
=
new
URL
(
event
.
request
.
url
);
const
cache
=
await
caches
.
open
(
CACHE
);
// `build`/`files` can always be served from the cache
//
if (ASSETS.includes(url.pathname)) {
//
const response = await cache.match(url.pathname);
//
if (response === undefined) throw new Error('Cache miss in build or files');
//
return response;
//
}
if
(
ASSETS
.
includes
(
url
.
pathname
))
{
const
response
=
await
cache
.
match
(
url
.
pathname
);
if
(
response
===
undefined
)
throw
new
Error
(
'
Cache miss in build or files
'
);
return
response
;
}
// for everything else, try the network first, but
// fall back to the cache if we're offline
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment