travis-r6s / gridsome-plugin-flexsearch

Add lightning fast search to Gridsome with FlexSearch
24 stars 7 forks source link

JSON compression maybe not ideal - ends up in more data transfer #39

Closed adamJLev closed 4 years ago

adamJLev commented 4 years ago

Hi there @thetre97 ,

First of all thanks for your lib its been quite handy! 😄

I was curious about the JSON compression you added to the lib recently, and did some testing of my own - and as it turns out, the raw json file is smaller - but after gzipping its actually bigger!

Makes sense since GZIP does well with repetitive data. And since gridsome usually gets deployed to a CDN, gzip is a given.

Here's what I found in my testing with my dataset, a pretty standard blog entries of dataset.

raw gzipped
compressed-json 131kb 31kb
json 233kb 26kb

So knowing that and also that the client and server both need to load compressed-json and the overhead of decompressing the blob in the client for every search, I think it may be better to not do this. Or maybe it should be configurable via a setting, but I dont think it should be the default. thoughts?

travis-r6s commented 4 years ago

@adamJLev Thanks for this, those results are interesting.

I believe I added it for my own sake as I had an ecommerce site with ~7k products, so the flexsearch JSON was huge (~20mb) and the compression really did help (as well as using brotli). I agree though, perhaps it is better to have it as a non-default option, in the case of smaller sites.