Compare commits

..

85 commits
v1.1.0 ... main

Author SHA1 Message Date
Ayo
6dbc9a0257 1.3.31 2026-01-25 19:56:53 +01:00
Ayo
22b192b8ca fix: remove duplicate "previously" post 2026-01-25 19:56:46 +01:00
Ayo
cc2e84f8d3 1.3.30 2026-01-25 19:54:11 +01:00
Ayo
7b26596b0b fix: homepage now link 2026-01-25 19:54:04 +01:00
Ayo
4344aa8a79 1.3.29 2026-01-25 19:52:07 +01:00
Ayo
f54aeb5fcc fix: now page 2026-01-25 19:52:00 +01:00
Ayo
e797e6905a 1.3.28 2026-01-25 19:07:07 +01:00
Ayo
3f0fa83286 chore(deps): update to latest 2026-01-25 19:06:30 +01:00
Ayo
246ec08076 1.3.27 2026-01-05 17:30:22 +01:00
Ayo
381db28b9f feat: use main.elk.zone for masto profile 2026-01-05 17:30:14 +01:00
Ayo
41a5bfc307 1.3.26 2026-01-04 15:38:35 +01:00
Ayo
88a6ae4b31 feat: change URL to org acronym 2026-01-04 15:38:27 +01:00
Ayo
4e9ebdbd95 1.3.25 2026-01-03 12:39:59 +01:00
Ayo
4efd5c9215 feat: add instagram 2026-01-03 12:39:06 +01:00
Ayo
317b5675b6 feat: put gh as last link 2026-01-03 12:35:51 +01:00
Ayo
adcd9af337 1.3.24 2026-01-03 12:33:01 +01:00
Ayo
d3eff70590 feat: use Elk to open Mastodon profile 2026-01-03 12:32:54 +01:00
Ayo
10ffd08754 1.3.23 2026-01-03 11:58:36 +01:00
Ayo
6e68472aa0 feat: update about page 2026-01-03 11:58:31 +01:00
Ayo
4ff4a5463f 1.3.22 2026-01-03 11:53:06 +01:00
Ayo
3ff47cc3a1 feat: update about page 2026-01-03 11:53:00 +01:00
Ayo
b10553cece 1.3.21 2026-01-03 11:35:40 +01:00
Ayo
544291d300 feat: remove interruption on the about page 2026-01-02 23:22:16 +01:00
Ayo
e021c2577b feat: update site description and about page content 2026-01-02 23:21:34 +01:00
Ayo
f3a20ee6aa feat: update site description 2026-01-02 23:16:53 +01:00
Ayo
ec46605828 1.3.20 2026-01-02 23:08:31 +01:00
Ayo
bc05c38cad feat: archive github-stats and bsky-fedi showcase items 2026-01-02 23:08:03 +01:00
Ayo
118df55742 1.3.19 2025-12-28 10:23:17 +01:00
Ayo
97063d1003 feat: update avatar 2025-12-28 10:23:11 +01:00
Ayo
c7edad0e56 1.3.18 2025-12-27 15:23:39 +01:00
Ayo
8f3e37aaba 1.3.17 2025-12-27 15:23:34 +01:00
Ayo
ebe1811e93 feat: update masto link 2025-12-27 15:23:28 +01:00
Ayo
c33da25571 1.3.16 2025-12-27 15:12:42 +01:00
Ayo
f681e3c4c3 chore: archive astro-github-stats 2025-12-27 15:12:26 +01:00
Ayo
f326027e58 feat: update site description 2025-12-27 15:07:59 +01:00
Ayo
5bd128b742 1.3.15 2025-12-15 14:19:40 +01:00
Ayo
086ecc0aab 1.3.14 2025-12-15 14:19:36 +01:00
Ayo
372efb9ef0 1.3.13 2025-12-15 14:19:17 +01:00
Ayo
988b138d91 1.3.12 2025-12-15 14:19:07 +01:00
Ayo
7f0c0934d6 feat: update showcase card for Simple TTS 2025-12-15 14:18:58 +01:00
Ayo
62a0c45842 chore: add example .env file 2025-11-21 11:12:29 +01:00
Ayo
1262e971c4 chore: update instructions on cache invalidation 2025-11-21 11:09:51 +01:00
Ayo
e097c27286 chore: update deployment instructions 2025-11-21 11:07:23 +01:00
Ayo
174f88776e 1.3.11 2025-11-21 11:05:12 +01:00
Ayo
5309732f80 1.3.10 2025-11-21 11:05:07 +01:00
Ayo
98f6aaddcd 1.3.9 2025-11-21 11:04:57 +01:00
Ayo
0d0a27038f feat: update bsky bridged csv 2025-11-21 11:04:53 +01:00
Ayo
1bce80b7b5 1.3.8 2025-11-21 10:41:11 +01:00
Ayo
fc0c3fcc12 1.3.7 2025-11-21 10:41:07 +01:00
Ayo
c630b75655 1.3.6 2025-11-21 10:40:46 +01:00
Ayo
6be1724d19 feat: update bsky bridged accounts csv 2025-11-21 10:40:39 +01:00
Ayo
38a822c1d5 chore: update readme 2025-11-18 09:52:47 +01:00
Ayo
c61becc74a 1.3.5 2025-11-18 09:50:31 +01:00
Ayo
14b5cf7976 chore: update version 2025-11-18 09:50:26 +01:00
Ayo
74eb4def38 1.3.4 2025-11-18 09:48:27 +01:00
Ayo
bff85a8e8f feat: update source code link 2025-11-18 09:47:52 +01:00
Ayo
fa8a760b70 1.3.3 2025-11-18 09:38:41 +01:00
Ayo
7b9c16ad46 feat: publish /tech-bsky-fedi 2025-11-18 09:38:19 +01:00
Ayo
3c0faf0254 1.3.2 2025-11-15 20:38:14 +01:00
Ayo
39673fb468 feat: link to masto about 2025-11-15 20:38:08 +01:00
Ayo
fa151985c1 1.3.1 2025-11-15 20:36:40 +01:00
Ayo
7b66d97af7 feat: empty now page 2025-11-15 20:36:27 +01:00
Ayo
92d58e9170 feat: update masto link to profile 2025-11-15 20:36:15 +01:00
Ayo
e57fad7b00 feat(links): update bsky 2025-10-30 18:08:28 +01:00
Ayo
3b5bf08541 feat: hide now link (for now) 2025-09-15 09:09:56 +02:00
Ayo
a8b77eca65 feat: update link sr.ht 2025-09-07 10:22:52 +02:00
Ayo
e79a6b29fc feat: add simple-tts in showcase 2025-09-05 14:11:15 +02:00
Ayo
29a29e4d63 chore(sw): update jsdoc 2025-08-26 01:23:30 +02:00
Ayo
343568042c refactor(sw): check for fallbackUrl 2025-08-26 00:53:34 +02:00
Ayo
f80807eebd chore(sw): add jsdoc 2025-08-26 00:47:00 +02:00
Ayo
f755588f58 chore: formatting 2025-08-26 00:25:55 +02:00
Ayo
410f43166c feat(sw): warn if failed to delete old cache 2025-08-26 00:20:08 +02:00
Ayo
0d0b9d44eb 1.3.0 2025-08-19 16:32:42 +02:00
Ayo
17e33c9659 feat(footer): show more social links; add forgejo 2025-08-19 16:28:03 +02:00
Ayo
e37836dd07 1.2.0 2025-08-02 11:02:59 +02:00
Ayo
3f13ac28c4 a11y: increase contrast ratio of link colors in dark mode 2025-08-02 11:02:21 +02:00
Ayo
f17673a404 chore: update deps & package manager 2025-08-02 10:50:42 +02:00
Ayo
02806a1563 chore: update lock files 2025-07-29 15:36:49 +02:00
Ayo
1e1e4d6d4a feat: use yolk.ayo.run for masto link 2025-07-28 13:21:49 +02:00
Ayo
516e9c459a Merge branch 'main' of git.sr.ht:~ayoayco/ayco.io-astro 2025-07-28 13:14:04 +02:00
Ayo
079deaab41 feat: use main.elk.zone for masto link 2025-07-28 13:13:58 +02:00
a30afc3f3d Merge branch 'main' of git@git.sr.ht:~ayoayco/ayco.io-astro 2025-07-22 09:19:29 +02:00
cb373e49fd chore: update readme 2025-07-22 09:19:14 +02:00
Ayo
03bd251103 1.1.1 2025-07-11 19:35:12 +02:00
Ayo
84e2c77078 feat(footer): link to source 2025-07-11 19:35:05 +02:00
20 changed files with 5377 additions and 17548 deletions

2
.env.example Normal file
View file

@ -0,0 +1,2 @@
# replace with correct IP, and rename the file to .env
HOST=123.456.789.00

1
.gitignore vendored
View file

@ -2,6 +2,7 @@
dist/
.output/
.astro/
.continue/
# dependencies
node_modules/

View file

@ -10,7 +10,7 @@ You need [node](https://nodejs.org) and [pnpm](https://pnpm.io).
```bash
# clone project
$ git clone git@git.sr.ht:~ayoayco/ayco.io-astro
$ git clone https://git.ayo.run/ayo/ayco.io-astro
# go into project dir
$ cd ./ayco.io-astro
@ -26,12 +26,25 @@ $ pnpm i
| ------------------- | ---------------------------------------------- |
| `pnpm run dev` | start dev server |
| `pnpm run build` | generate static files to `dist` directory |
| `pnpm run deploy` | upload to my server |
| `pnpm run deploy` | upload to my server |
| `pnpm run prep:now` | back up and clear current `now page` constants |
> For the deploy script, you need to add an environmental variable named HOST
## Deployment
-----
For the script `npm run deploy`, you need to add an environmental variable named HOST containing the IP address of the host server. This will scp the build files into the server.
> Just keep building.
> ~Ayo
You can do this by adding a `.env` file with the following content (replace the IP):
```bash
# .env
HOST=123.456.789.00
```
There is a service worker (`src/sw.mjs`) that caches assets on client browsers. For cache invalidation, the version property in package.json is used. Increment the version via `npm version patch` (or `minor`, `major`) if there is a significant change in the website's assets.
If you want to run build before deploying, do `npm run build:deploy`
---
_Just keep building._<br />
_~Ayo_

View file

@ -1,9 +1,9 @@
---
import { Code } from 'astro:components'
import { Image } from 'astro:assets'
import Footer from '../components/Footer.astro'
import Layout from '../layouts/Layout.astro'
import importedCode from '../../public/following_accounts.csv?raw'
import Footer from '../../components/Footer.astro'
import Layout from '../../layouts/Layout.astro'
import importedCode from '../../../public/following_accounts.csv?raw'
const csvToArray = (content: string) => {
return content

13094
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
{
"name": "@ayco/personal-website",
"type": "module",
"version": "1.1.0",
"version": "1.3.31",
"private": true,
"scripts": {
"astro": "astro",
@ -12,7 +12,8 @@
"lint": "eslint . --config eslint.config.mjs --cache",
"format": "prettier . --write",
"check": "npm run format && npm run lint",
"deploy": "eval $(grep '^HOST' .env) && scp -r dist ayo@$HOST:~/ayco.io-flask",
"predeploy": "npm version patch && npm run build",
"deploy": "npm run predeploy && eval $(grep '^HOST' .env) && scp -r dist ayo@$HOST:~/ayco.io-flask",
"build:preview": "npm run build && astro preview",
"build:deploy": "npm run build && npm run deploy",
"copy:dist": "npm run build && cp -R dist ../ayco.io-flask/",
@ -22,35 +23,35 @@
"devDependencies": {
"@astro-reactive/form": "^0.10.1",
"@astro-reactive/validator": "^0.5.1",
"@astrojs/sitemap": "^3.4.1",
"@astrojs/sitemap": "^3.7.0",
"@ayco/astro-sw": "^0.8.14",
"@eslint/compat": "^1.3.1",
"@eslint/js": "^9.30.1",
"@eslint/compat": "^2.0.1",
"@eslint/js": "^9.39.2",
"@iconify-json/mdi": "^1.2.3",
"@iconify-json/simple-icons": "^1.2.42",
"@iconify-json/tabler": "^1.2.19",
"@typescript-eslint/parser": "^8.36.0",
"astro": "^5.11.0",
"@iconify-json/simple-icons": "^1.2.67",
"@iconify-json/tabler": "^1.2.26",
"@typescript-eslint/parser": "^8.53.1",
"astro": "^5.16.15",
"astro-eslint-parser": "^1.2.2",
"astro-github-stats": "^0.8.0",
"astro-icon": "^1.1.5",
"consola": "^3.4.2",
"eslint": "^9.30.1",
"eslint-plugin-astro": "^1.3.1",
"eslint": "^9.39.2",
"eslint-plugin-astro": "^1.5.0",
"eslint-plugin-jsx-a11y": "^6.10.2",
"globals": "^16.3.0",
"globals": "^17.1.0",
"husky": "^9.1.7",
"jiti": "^2.4.2",
"lint-staged": "^16.1.2",
"jiti": "^2.6.1",
"lint-staged": "^16.2.7",
"pathe": "^2.0.3",
"prettier": "^3.6.2",
"prettier": "^3.8.1",
"prettier-plugin-astro": "^0.14.1",
"rehype-stringify": "^10.0.1",
"remark-parse": "^11.0.0",
"remark-rehype": "^11.1.2",
"tslib": "^2.8.1",
"typescript": "^5.8.3",
"typescript-eslint": "^8.36.0",
"typescript": "^5.9.3",
"typescript-eslint": "^8.53.1",
"unified": "^11.0.5"
},
"lint-staged": {
@ -62,5 +63,5 @@
"prettier --write"
]
},
"packageManager": "pnpm@7.28.0+sha1.48be3292711ad554fe944f6caaf9b0f5477524fe"
"packageManager": "pnpm@10.14.0"
}

File diff suppressed because it is too large Load diff

BIN
public/ayo-2025-sm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
public/ayo-2025.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

View file

@ -8,8 +8,7 @@ jay.bsky.team@bsky.brid.gy, true, false,
b0rk.jvns.ca@bsky.brid.gy, true, false,
seldo.com@bsky.brid.gy, true, false,
nerdy.dev@bsky.brid.gy, true, false,
wongmjane.com@bsky.brid.gy, true, false,
samuel.bsky.team@bsky.brid.gy, true, false,
samuel.fm@bsky.brid.gy, true, false,
laurenshof.online@bsky.brid.gy, true, false,
bell.bz@bsky.brid.gy, true, false,
matrix.org@bsky.brid.gy, true, false,
@ -29,10 +28,9 @@ jacobhands.com@bsky.brid.gy, true, false,
malstrom.me@bsky.brid.gy, true, false,
shuuji3.xyz@bsky.brid.gy, true, false,
intenttoship.dev@bsky.brid.gy, true, false,
haoqun.dev@bsky.brid.gy, true, false,
element.io@bsky.brid.gy, true, false,
e18e.dev@bsky.brid.gy, true, false,
danabra.mov@bsky.brid.gy, true, false,
heydonworks.bsky.social@bsky.brid.gy, true, false,
heydonworks.com@bsky.brid.gy, true, false,
danielroe.dev@bsky.brid.gy, true, false,
patak.dev@bsky.brid.gy, true, false,

1 Account address Show boosts Notify on new posts Languages
8 b0rk.jvns.ca@bsky.brid.gy true false
9 seldo.com@bsky.brid.gy true false
10 nerdy.dev@bsky.brid.gy true false
11 wongmjane.com@bsky.brid.gy samuel.fm@bsky.brid.gy true false
samuel.bsky.team@bsky.brid.gy true false
12 laurenshof.online@bsky.brid.gy true false
13 bell.bz@bsky.brid.gy true false
14 matrix.org@bsky.brid.gy true false
28 malstrom.me@bsky.brid.gy true false
29 shuuji3.xyz@bsky.brid.gy true false
30 intenttoship.dev@bsky.brid.gy true false
haoqun.dev@bsky.brid.gy true false
31 element.io@bsky.brid.gy true false
32 e18e.dev@bsky.brid.gy true false
33 danabra.mov@bsky.brid.gy true false
34 heydonworks.bsky.social@bsky.brid.gy heydonworks.com@bsky.brid.gy true false
35 danielroe.dev@bsky.brid.gy true false
36 patak.dev@bsky.brid.gy true false

View file

@ -32,8 +32,8 @@ const year = new Date().getFullYear()
aria-label={linkObj.text}
>
<Icon
width="1.5em"
height="1.5em"
width="1em"
height="1em"
name={`${linkObj.set ?? 'simple-icons'}:${linkObj.icon}`}
/>
</a>
@ -47,7 +47,7 @@ const year = new Date().getFullYear()
<a href="/">Ayo Ayco</a>. This website <a
href="https://ayos.blog/stopped-tracking-on-my-sites"
>does not track users</a
>.
>. See the <a href="https://git.ayo.run/ayo/ayco.io-astro">source code.</a>
</p>
<WebRings />

View file

@ -7,7 +7,7 @@ export interface Props {
const defaultDescription =
'Professional software engineer specializing in web development with a decade of experience building web applications for both private businesses and government-funded high-impact projects utilizing web technologies, IoT, data viz/insights, remote sensing, and GIS'
const defaultTitle = 'Ayo Ayco - Web Dev, Engineer, Leader, Thinker'
const defaultTitle = 'Ayo Ayco - Tech Leader, Software Engineer, Web Developer'
const defaultOgImage = 'ayo.png'
let {

View file

@ -40,14 +40,19 @@ export const links: Link[] = [
export default links
export const footerLinks: Link[] = [
{
text: "Ayo's Forge",
url: 'https://git.ayo.run/ayo/',
icon: 'git',
},
{
text: 'SourceHut',
url: 'https://ayco.io/sh/',
url: 'https://sr.ht/~ayoayco',
icon: 'sourcehut',
},
{
text: 'Mastodon',
url: 'https://social.ayco.io/public/local',
url: 'https://main.elk.zone/social.ayco.io/@ayo',
icon: 'mastodon',
},
{
@ -55,6 +60,21 @@ export const footerLinks: Link[] = [
url: 'https://metapixl.com/@ayo',
icon: 'pixelfed',
},
{
text: 'Bluesky',
url: 'http://bsky.app/profile/ayo.ayco.io',
icon: 'bluesky',
},
{
text: 'Instagram',
url: 'https://www.instagram.com/ayoayco/',
icon: 'instagram',
},
{
text: 'LinkedIn',
url: 'https://www.linkedin.com/in/ayoayco/',
icon: 'linkedin',
},
{
text: 'GitHub',
url: 'https://ayco.io/gh',

View file

@ -103,7 +103,7 @@ const { title, description, ogImage } = Astro.props
@media (prefers-color-scheme: dark) {
a {
color: var(--color-brand-blue-3);
color: var(--text-color-light);
}
}
</style>

View file

@ -8,51 +8,33 @@ import Footer from '../components/Footer.astro'
<h1>Ayo Ayco</h1>
<p>ᜈᜄ᜔ᜋᜓᜎ ᜐ ᜉᜒᜇ̢̟ᜎᜐ᜔ ᜅ᜔ ᜐᜒᜎᜅᜈᜈ᜔</p>
<p>
Frontend guy who likes server adventures, coding, and linux. Passionate
about the indieweb, digital sovereignty, and kindness.
Technical engineering leader experienced in web development, software
architecture, and community building. Passionate about the indieweb,
digital sovereignty, and kindness.
</p>
<details>
<summary>
Hey there! I interrupt this page for a message from this website's
sponsor...
</summary>
<p>
<strong>Myself!</strong> Thank you for wanting to read a bit more about me.
<!--Some people shy away from writing things about themselves, and thus looks negatively at others who do. But that shouldn't be the case!-->
I find it helpful to have a single canonical <code class="inline-code"
>/about</code
> page with these significant information. It is always a work in progress
(like me), and to be honest, I do this mostly as a reminder as the world
continue to impose identity onto us. Cheers to celebrating differences!
</p>
<small> Now back to the rest of the web page... </small>
</details>
<p>
I am a newbie engineering manager at a large global bank headquartered in
Amsterdam. I'm also a certified software architecture professional
(CPSAF®) by <a href="https://isaqb.org" target="_blank">isaqb.org</a>.
I am an engineering manager at <a href="https://ing.com">ING</a> and a certified
software architecture professional (CPSAF®) by <a
href="https://isaqb.org"
target="_blank">iSAQB</a
>.
</p>
<p>
In my spare time, when I have energy, I find it fun building <a
href="/showcase">hobby projects</a
>, running self-hosted services at <a href="https://ayo.run">ayo.run</a>,
and volunteering to <a
href="https://ayos.blog/why-fediverse/"
target="_blank">Fediverse</a
In my spare time, I find it fun building <a href="/showcase">projects</a>,
running self-hosted services at <a href="https://ayo.run">ayo.run</a>, and
volunteering to <a href="https://ayos.blog/why-fediverse/" target="_blank"
>Fediverse</a
> projects like <a href="https://elk.zone">elk.zone</a>,
<a href="https://m.webtoo.ls/public/local">webtoo.ls</a>, and <a
href="https://m.webtoo.ls/@vitest">vitest's fedi presence</a
>.
</p>
<p>
In a previous life, I've volunteered much of my weekends into teaching
kids, leading groups of students, planting a church, and facilitating
focus group discussions with entrepreneurial founders, where I learned a
lot about the power of multi-generational & multi-cultural communities.
I've volunteered much of my early years into leadership trainings,
teaching & leading groups of students, planting a church, and facilitating
focus group discussions with entrepreneurial founders, where I learned the
power of multi-generational & multi-cultural communities.
</p>
<h2 id="contact">Contact info</h2>
<ul>
<li>✉️ Email: <a href="mailto:ayo@ayco.io">ayo@ayco.io</a></li>

View file

@ -21,7 +21,7 @@ import now from '../constants/now.json'
<img
class="u-photo highlighted-section__content__profile-picture"
alt="Ayo Ayco's avatar"
src="/ayo-sm.png"
src="/ayo-2025-sm.png"
width="140"
height="140"
/>
@ -29,7 +29,7 @@ import now from '../constants/now.json'
<h1 title="Ayo Ayco | Software Engineer + Web Developer">
Hi, I'm <span class="heavy-text">Ayo</span>!
</h1>
<!-- <a href="https://forms.ayo.run/form/tnz7FybY" class="now-wrapper"> -->
<!--a href="https://forms.ayo.run/form/tnz7FybY" class="now-wrapper"-->
<a href="/now" class="now-wrapper">
<span class="now-label">now</span>
<span class="status">{now.title}</span>

View file

@ -16,6 +16,12 @@ import Card from '../components/Card.astro'
>.
</p>
<ul>
<Card
newTab
href="https://git.ayo.run/ayo/simple-tts#readme"
title="Simple TTS"
body="A machine learning text-to-speech program for the terminal"
/>
<Card
newTab
href="https://mcfly.js.org"
@ -69,11 +75,6 @@ import Card from '../components/Card.astro'
title="Reactive Form"
body="The reactive form component for Astro 🔥"
/>
<Card
href="/showcase/astro-github-stats"
title="GitHub Stats"
body="Embed GitHub stats on your Astro page ✨"
/>
</ul>
</main>
<Footer />

View file

@ -6,17 +6,39 @@
const cacheName = `${__prefix ?? 'app'}-v${__version ?? '000'}`
const forceLogging = true
/**
* Cleans up old service worker caches by deleting any cache that doesn't match the current cache name.
* This ensures only the current version of the application's cache is retained.
* @async
* @function cleanOldCaches
* @returns {Promise<void>} A promise that resolves when old caches have been deleted
*/
const cleanOldCaches = async () => {
const allowCacheNames = [cacheName]
const allCaches = await caches.keys()
allCaches.forEach((key) => {
if (!allowCacheNames.includes(key)) {
console.info('Deleting old cache', key)
caches.delete(key)
caches
.delete(key)
.then(() => {
console.info('Successfully deleted cache:', key)
})
.catch((error) => {
console.warn('Failed to delete old cache:', key, error)
})
}
})
}
/**
* Adds specified resources to the service worker cache.
* This function is used to cache static assets for offline access.
* @async
* @function addResourcesToCache
* @param {Array<string>} resources - An array of URLs representing the resources to be cached.
* @returns {Promise<void>} A promise that resolves when all resources have been successfully added to the cache.
*/
const addResourcesToCache = async (resources) => {
const cache = await caches.open(cacheName)
console.info('adding resources to cache...', {
@ -34,6 +56,14 @@ const addResourcesToCache = async (resources) => {
}
}
/**
* Puts a response in the cache.
* @async
* @function putInCache
* @param {Request} request - The request to be cached.
* @param {Response} response - The response to be cached.
* @returns {Promise<void>} A promise that resolves when the response has been added to the cache.
*/
const putInCache = async (request, response) => {
const cache = await caches.open(cacheName)
@ -49,9 +79,6 @@ const networkFirst = async ({ request, fallbackUrl }) => {
try {
// Try to get the resource from the network for 5 seconds
const responseFromNetwork = await fetch(request.clone())
// response may be used only once
// we need to save clone to put one copy in cache
// and serve second one
putInCache(request, responseFromNetwork.clone())
console.info('using network response', responseFromNetwork.url)
return responseFromNetwork
@ -64,11 +91,13 @@ const networkFirst = async ({ request, fallbackUrl }) => {
return responseFromCache
}
// Try the fallback
const fallbackResponse = await cache.match(fallbackUrl)
if (fallbackResponse) {
console.info('using fallback cached response...', fallbackResponse.url)
return fallbackResponse
// If fallback is provided, try to use it, otherwise return error
if (fallbackUrl) {
const fallbackResponse = await cache.match(fallbackUrl)
if (fallbackResponse) {
console.info('using fallback cached response...', fallbackResponse.url)
return fallbackResponse
}
}
// when even the fallback response is not available,