←back to thread

260 points gherkinnn | 2 comments | | HN request time: 0.001s | 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. cuu508 ◴[] No.42164623[source]
Set max-age in the Cache-Control header to a high value and the browser will not need to revalidate. When deploying a new version, "invalidate" the browser cache by using a different filename.
replies(1): >>42164750 #
2. austin-cheney ◴[] No.42164750[source]
Or keep the file name and send the file with a query string of some changed numeric value