I've written about this problem that has bothered me all these weeks and months, and that was about the 'search' bar feature on my website. First, it was loading literally all the website twice for every page, to index it, and then allow the user to search it. So the most obvious change was to cause it to load only when the websearch button was clicked. As majority of the users don't need the feature, they shouldn't have to pay the search penalty. Then the goal was to pre-index the search, as there's no point in using all the capacity user-side indexing the website everytime, and causing several second jitters. That was done too. Then the goal was to 'compress' and 'decompress' the pre-generated index, so that the network wouldn't have to transfer all that much data, and that was done too. Finally, I plugged the sockets in, and realized a massive error in my ways. The index search returns not the object (because then you'd need the entire object around!) but just a pointer to the original object. So at some point you do need some part of the object to return to show it on the search window! But how!
My first idea was to do http range searches but uhh ajax requests for jquery didn't help me. The second idea was to use sqlite-js to be able to query a database full of my blog posts...the idea is to publish the entire blog on the github inside the db, and load it using range requests. It almost worked, but getting sqlite-webasm turned out to be a bigger project than I anticipated, and my project wasn't to learn wasm, so that was abandoned. And then I thought of the simplest of solutions. I'd save a 'summary' version of every post entry as a separate page under the identifier path, and when the search index returned an identifier, go fetch that summary page. And that's what I implemented! It's worked swimmingly well, and I'm specially proud of the fact that the search page loads gradually, as it gets around to loading less-relevant searches from the archives.
So now that is done, I need to be focusing more on the actual content, because the goal is to get v1 of the website out this weekend, and then take it easy. Look at some design stuff etcetera, but I need some rest from the whole workflow...stuff.
No comments:
Post a Comment
Tell me what you think. I'll read, promise.