When you start typing out a google search, it lists a bunch of options to autocomplete your search. This made me wonder how that autocomplete works. Is there a cache stored somewhere in the browser? That seems inefficient to me, so does it actually send a request to Google? If so, are these unfinished search requests stored or logged anywhere like typical searches?
As inefficient as it sounds, that's exactly how it works.
Head on over to google.com, bring up your developer tools in your browser (CTRL+SHIFT+I or CTRL+OPTION+I in Chrome), click the network tab, and then start typing in the search box. You'll see a series of GET requests to to the
/complete/search url path, like this:
https://www.google.com/complete/search?client=psy-ab&q=he https://www.google.com/complete/search?client=psy-ab&q=hel https://www.google.com/complete/search?client=psy-ab&q=hell https://www.google.com/complete/search?client=psy-ab&q=hello
You'll probably have a bunch of other query parameters in there, but the client identifier and the query are the two required ones. The return from that request contains the autocomplete list for the substring you typed.
This means that autocomplete queries follow the same storage rules as not-autocomplete queries; if you have a proxy or cache or whatever, they'd appear there.
There's a couple of special rules at play, though: since they're XHR queries sent in the background rather than queries you type into the URL bar, the browser doesn't put them in your navigation history. And (IIRC) Google only uses this feature if you're on TLS, so it won't ever send these queries over plain text. And finally, since Google knows that they're autocomplete requests instead of actual searches, they don't appear in your stored search history associated with your account.
In terms of efficiency, this is why Google is investing so much in protocols like SPDY and QUIC (variations of which are now being standardized as HTTP/2 and HTTP/3). These allow extremely low-overhead HTTP traffic, getting it down to as low as one UDP packet in each direction for one of these autocomplete requests.
Is there a cache stored somewhere in the browser?
This is really easy to test: enter a search term in the search bar, then disconnect the network and try the same search term.
I just tried this to confirm again, and there is no autocomplete without a network.
Every character you type is sent to Google to auto-suggest completions.
If so, are these unfinished search requests stored or logged anywhere like typical searches?
We can only go with what is publicly disclosed to us. We cannot know what might be done on the backend. As for what is publicly disclosed, if you go into your Google account and look up the stored search data, only the submitted searches are stored.
From a practical point of view, it makes sense that only submitted searches are logged for any amount of time. That's the only data that will have any long term value. There is potential that unsubmitted queries are logged temporarily to improve the auto-suggest features in the short term.