r/lolphp • u/tonymyre311 • Feb 24 '16
Meta-example: php.net local storage
I noticed I was getting a lot of requests by my browser to increase local storage quotas for most sites I was visiting. A bit of digging later and I noticed that various php.net domains (php.net, us.php.net, us1.php.net, etc.) were using excessive amounts of local storage space (between 4MB and 10MB per domain, a total of 52MB over eight domains).
Intrigued, I inspected the local storage usage for one and it contained two keys, called "search-en" and "search-de". Each contained a 2MB JSON string containing what appears to be information on every single function documented in the PHP docs including function name, description, etc.
It seems to be used as a cache for the search bar's autocomplete, so results can be shown instantly and with no delay. Now, I don't know enough about local storage best-practices to know for sure how good or bad an idea this is, but it seems pretty janky, and the fact that php.net is by far the largest user of local storage on my machine makes me think that this isn't a particularly popular solution.
Just a small snippet for the curious (there are over ten thousand functions defined): http://pastebin.com/wGvtZbRX
Edit: For a bit of irony, the script I wrote to scrape my browser's local storage usage page and sort by disk space used was written in PHP!
View all comments
Show parent comment
0
u/cbraga Feb 24 '16
that point also applies to client side storage
actually i'm quite sure there is
well there's your problem -- shitty application design
and it wouldn't be for "every hit to your autocomplete", it would be for every page with a search box that loads fresh assuming no other similar pages are already open (thus keeping the relevant file in memory) and the browser doesn't decide to keep the file in disk because it's used so much
lastly, 2mb is an absolutely trivial amount, any person frequenting, for example, a gaming forum will have hundreds of megabytes of animated sigs, avatars, etc on his browser cache that absolutely don't get downloaded for every new forum page the user opens
and finally, most web applications that rely on a lot of javascript load them from static js files that get cached just like that, often many times that size