←back to thread

260 points gherkinnn | 2 comments | | HN request time: 0.651s | source
Show context
mh-cx ◴[] No.42164537[source]
I wonder why the article doesn't mention utilizing the browser cache for your static CSS and JS assets instead of introducing a service worker as first measure.

Few years ago I built a shopping site MPA this way and the page transitions were almost not noticable.

replies(7): >>42164573 #>>42164584 #>>42164743 #>>42168597 #>>42169927 #>>42170948 #>>42173755 #
thangngoc89 ◴[] No.42164584[source]
Edit: below isn’t true. You could set immutable in cache header and the browser wouldn’t verify.

—— Original comment:

With browser cache, the browser stills need to send a HEAD request to see if the content was modified. These requests are noticeable when networks are spotty (train, weak mobile signals…)

Service Worker could cache the request and skip the head requests all together

replies(2): >>42164606 #>>42164623 #
1. 01HNNWZ0MV43FF ◴[] No.42164606[source]
Not if you tell the browser it's guaranteed fresh for 10 minutes and then use cache-busting in the URL
replies(1): >>42164622 #
2. thangngoc89 ◴[] No.42164622[source]
Oh yeah. The immutable tag right? Total forgot about that