3 ms·
Good point - what I've done is allow you to piggyback more than one lookup onto a single request. so the plugin will batch them in groups of 4. does that make s
by darraghcurran 18y ago
Good point - what I've done is allow you to piggyback more than one lookup onto a single request. so the plugin will batch them in groups of 4. does that make sense?
- pmjordan 18y agoWell, on the server you're still starting N requests based on my batch request. I guess combined with caching that can make sense, yes. Even so, I'd probably want to implement my own [1] when setting up my own web app for reliability/trust reasons, and because of same-origin restrictions on client-side scripting. (XHR does support not following redirects, but it's kind of pointless with same-origin policy) [1] I did exactly that for http://tweetoftheyear.com/ http://tweetoftheyear.com/ in clojure: (defn lookup-redirect [url] (try (let [response (http-client/url-do url "HEAD" {:follow-redirect false})] (when (#{301 302 303 307} (:return-code response)) (first (get (:header response) "Location")))) (catch java.lang.Throwable t nil)))
- darraghcurran 18y agoI thought so, and I do cache everything nicely in memcache and db. Also it's hard or maybe even impossible? to reliably fetch arbitrary short url using javascript - exposing it as a simple json api makes this easy.
- pmjordan 18y agoYeah, it's only possible on the same hostname as the page you're on, which limits the usefulness and makes the server-side lookup necessary. The JSON solution will only work via a foreign host with a <script> tag as far as I know, which again is something of a trust issue.
- darraghcurran 18y agonice - I've been meaning to learn a bit of clojure. I hear your point on wanting to set up your own - and as you've shown it is easy to do.