pagefind icon indicating copy to clipboard operation
pagefind copied to clipboard

[Question] "Slow" first load

Open gustaveWPM opened this issue 2 years ago • 8 comments

Hello there!

I noticed that the first search is always slower than the others.

For example: https://pagefind.app/

If I search hello, I will have a little delay ("Searching for hello..."). Then, if I search hello again, the search will be really fast.

But if I refresh the page, then start again to search hello, I will have the little delay again.

Is it planned to populate the browser cache (like requests caching) to improve this?

gustaveWPM avatar Apr 16 '24 19:04 gustaveWPM

The browser cache should be caching the relevant indexes/fragments, and if I do the same action as described I'm not seeing any significant delay — and the index chunks are served from my browser cache.

There is one request in the flow which is explicitly uncached, which is the request for the entry JSON file. (see https://pagefind.app/pagefind/pagefind-entry.json )

This file will never be cached, as the contents are used to cache-bust the rest of the requests. If you're on a slower connection then pulling this file might cause the small delay, but that's the only thing I can think of that would affect a refresh.

bglw avatar Apr 16 '24 20:04 bglw

The browser cache should be caching the relevant indexes/fragments, and if I do the same action as described I'm not seeing any significant delay — and the index chunks are served from my browser cache.

There is one request in the flow which is explicitly uncached, which is the request for the entry JSON file. (see https://pagefind.app/pagefind/pagefind-entry.json )

This file will never be cached, as the contents are used to cache-bust the rest of the requests. If you're on a slower connection then pulling this file might cause the small delay, but that's the only thing I can think of that would affect a refresh.

Interesting! I'll try with someone who has a better connection and computer than me.

gustaveWPM avatar Apr 16 '24 20:04 gustaveWPM

Indeed, this is caused by my poor hardware and connection. Sorry, I should have checked it before writing this issue.

gustaveWPM avatar Apr 16 '24 20:04 gustaveWPM

No worries! It's still good to hear from people that the experience can be slow, I'll keep that in mind :)

bglw avatar Apr 16 '24 20:04 bglw

No worries! It's still good to hear from people that the experience can be slow, I'll keep that in mind :)

I'm exaggerating when I say it's slow. There's just a perceptible delay in my reaction time, but I don't have to wait more than a second either.

It's only on the first request, so maybe it's due to some computations more than connection.

gustaveWPM avatar Apr 16 '24 21:04 gustaveWPM

Oh... Finally, it looks like this is slower on Firefox than on Chrome. I'm curious.

gustaveWPM avatar Apr 16 '24 22:04 gustaveWPM

Hmm — my primary browser is Firefox and I've never noticed an issue.

OS / Firefox version?

bglw avatar Apr 16 '24 22:04 bglw

Hmm — my primary browser is Firefox and I've never noticed an issue.

OS / Firefox version?

Ubuntu 22.04.4 LTS x86_64 Kernel: 6.5.0-27-generic CPU: Intel i3-10110U (4) @ 4.100GHz GPU: Intel CometLake-U GT2 [UHD Graphics] Memory: 7674MiB

Firefox 125.0

Everything is faster on Chromium on this setup.

gustaveWPM avatar Apr 16 '24 22:04 gustaveWPM