DEV Community

Cover image for Updated my portfolio
Melvin Jones Repol
Melvin Jones Repol

Posted on

Updated my portfolio

Yes here i go again. sometimes i dont feel like the new one so i changed it.

mrepol742.github.io

This update includes performance improvements. So now i removed dns-prefetching and updates some images reducing the list of 3rd party domains.

I also updated the service workers to make it simple this service worker will cache the site files assets folder which has the bootstraps jquery etc... Thought it won't gonna catch other files like html, js or css files since they usually changed daily or so..

const cacheName = 'mrepol742v2';
self.addEventListener('install', (event) => {
event.waitUntil(caches.open(cacheName));
});
self.addEventListener('fetch', async (event) => {
if ((event.request.destination === 'image' || event.request.url.includes("/assets/")) && event.request.url.includes("https://mrepol742.github.io/")) {
event.respondWith(caches.open(cacheName).then((cache) => {
return cache.match(event.request).then((cachedResponse) => {
return cachedResponse || fetch(event.request.url).then((fetchedResponse) => {
cache.put(event.request, fetchedResponse.clone());
return fetchedResponse;
});
});
}));
} else {
return;
}
});
view raw sw.js hosted with ❤ by GitHub

The event.request.destination === image checks if the request file is an image or event.request.url.includes("/assets/") checks if the requested file is located inside the assets folder and event.request.url.includes("https://mrepol742.github.io/") then cache else load over the network.

This system saves traffic and makes the site loads faster.
Running a service worker is simple as control + c.

Asside from it i also updated titles, images etc..
If you have time you can check it out at https://mrepol742.github.io/
and also Its Open Source https://github.com/mrepol742/mrepol742.github.io/

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay