Slimmer dan je proxy(-admins)!

Proxies zijn vreemde dingen met een olifantengeheugen en bezorgen je soms een oude versie van een file die je van internet wilt plukken. Dat willen we niet en gelukkig is daar een simpele oplossing voor, een eenvoudige “bookmarklet” (stukje javascript-code dat vanuit de bookmarks wordt opgeroepen) zal die proxy wel even voor U temmen.
Een voorbeeld: om de meest recente versie van het fantastische Gilles Peterson’s Worldwide van de StuBru servers te plukken, zonder dat de bedrijfsproxy me de versie van bv. vorige week of afgelopen maand geeft, heb ik ipv dit:

http://download.streampower.be/vrt/stubru/41_41gpwo-hi.mp3

het volgende in mijn bookmarks:

“javascript:(function(){rnd=Math.floor(Math.random()*1000000);url = ‘http://download.streampower.be/vrt/stubru/41_41gpwo-hi.mp3?n=’ + rnd;location.href=url;})()

Deze bookmarklet zal elke keer opnieuw een willekeurig cijfer generen en dat aan de URL plakken (die wordt dan bv. http://download.streampower.be/vrt/stubru/41_41gpwo-hi.mp3?n=234219). Omdat proxies bestanden in cache bijhouden aan de hand van de volledige URL, zal de proxy die file (inclusief random number) niet in zijn geheugen kunnen terugvinden en wordt er speciaal voor jou een nieuwe versie van dat bestand afgehaald. Veel luistergenot!

De bonsaikittens van de toekomst: Genpets

Wie al een tijdje op internet rondwaart, herinnert zich de bonsaikittens nog wel; jonge katjes die in een bokaal werden geperst en daar -net als een bonsai-boompje- artificieel klein gehouden werden. Makkelijk in onderhoud, neemt niet te veel plaats in beslag, geen dampende kattebakken meer … Ik kreeg in de tijd tientallen mails van verontrustte vrienden en kennissen die hun verontwaardiging wilden uitschreeuwen en me vroegen om de petitie mee te tekenen. Maar bonsaikittens, mijnheer, die bestonden eigenlijk niet. Dat is een hoax mevrouw, een fabeltje, een grap van enkele studenten (van het MIT dan nog wel, ge zout denken dat ze daar toch beters te doen hebben toch?).
Soit, die kat zit ondertussen al een tijdje terug in de zak (is dat zoveel beter dan een bokaal?) en we zijn 7 jaar verder. Aangezien de tijd niet stilstaat, is het hoog tijd voor nieuw dierlijk gezelschap. Ik stel u voor: de Genpets!
genpets
Deze huisdieren van de toekomst zijn biogenetisch geproduceerde beestjes die in de verpakking in een soort kunstmatige winterslaap zitten. Eenmaal uitgepakt heb je een low-maintenance vriendje voor 1 of 3 jaar dat ergens tussen saai speelgoed en ouderwetse stinkende huisdieren inzit;

“Genpets™ have limited mobility. Like dolls, puppies or human babies, they must be looked after and cared for. Upon waking from its dormant state the Genpet™ will immediately bond or imprint to your child. The Genpet™ line-up pulls its basis from a natural stage of evolution in the market. Dolls and robotic toys quickly become tiresome, while traditional pets require a high level of upkeep. Genpets™ however, learn and adapt. They are living pets, but better, modified to be as reliable, dependable and efficient as any other technology we use in our busy lives.”

Voor wie nog zou twijfelen, dit is inderdaad ook weer een hoax (en meer). De bedenker is Adam Brandejs, een Canadees kunstenaar die op zijn site het hoe en waarom van zijn Genpets-project uitlegt:

“Slow down, stop, and think. Think about why it is that you probably, like most people seeing the work, find it highly disturbing on some level, and yet, still want to buy one. Why is it that you’re so inclined to buy things, no matter what? And what is it that makes this concept so disturbing, or not disturbing to you? Consider both sides of the issue, and consider how we treat animals in farms, and pet stores today. How does that relate?”

Denk daar maar eens over na, terwijl je dit paasweekend lieve kleine gele kuikentjes als speelgoed weggeeft …

Cache header magic (or how I learned to love http response headers)

Is your site dead slow? Does it use excessive bandwidth? Let me take you on a short journey to the place where you can lessen your worries: the http-response-headers, where some wee small lines of text can define how your site is loaded in cached.
So you’re interested and you are going to read on? In that case let me skip the foolishness (I’m too tired already) and move on to the real stuff. There are 3 types of caching-directives that can be put in the http response: permission-, expiry- and validation-related headers:

  1. Permission-related http response headers tell the caching algorithm if an object can be kept in cache at all. The primary way to do this (in HTTP/1.1-land) is by using cache-control:public, cache-control:private or cache-control:nocache. Nocache should be obvious, private indicates individual browser caches can keep a copy but shared caches (mainly proxies) cannot and public allows all caches to keep the object. Pre-http/1.1 this is mainly done by issuing a Last-Modified-date (Last-Modified; although that in theory is a validation-related cache directive) which is set in the future.
  2. The aim of expiry-related directives is to tell the caching mechanism (in a browser or e.g. a proxy) that upon reload the object can be reused without reconnecting to the originating server. These directives can thus help you avoid network roundtrips while your page is being reloaded. The following expiry-related directives exist: expires, cache-control:max-age, and cache-control:s-maxage. Expires sets a date/time (in GMT) at which the object in cache expires and will have to be revalidated. Cache-control:Max-age and Cache-control:s-maxage (both of which which take precedence if used in conjunction with expires) define how old an object may get in cache (using either the ‘age’ http response header or calculating the age using (Expires – Current date/time). s-maxage is to be used by shared caches (and takes precedence over max-age there), whereas max-age is used by all caches (you could use this to e.g. allow a browser to cache a personalised page, but prohibit a proxy from doing so). If neither expires, cache-control:max-age or cache-control:s-maxage are defined, the caching mechanism will be allowed to make an estimate (this is called “heuristic expiration“) of the time an object can remain in cache, based on the Last-Modified-header (the true workhorse of caching in http/1.0).
  3. Validation-related directives give the browser (or caching proxy) a means by which an object can be (re-)validated, allowing for conditional requests to be made to the server and thus limiting bandwith usage. Response-headers used in this respect are principally Last-Modified (date/timestamp the object was … indeed modified the last time) and ETag (which should be a unique string for each object, only changing if the object got changed).

And there you have it, those are the basics. So what should you do next? Perform a small functional analysis of how you want your site (html, images, css, js, …) to be cached at proxy or browser-level. Based on that tweak settings of your webserver (for static files served from the filesystem, mostly images, css, js) to allow for caching. The application that spits out html should include the correct headers for your pages so these can be cached as well (if you want this to happen, off course). And always keep in mind that no matter how good you analyze your caching-needs and how well you set everything up, it all depends on the http-standards (be it HTTP/1.0 or 1.1) the caching applications follows (so you probably want to include directives for both HTTP/1.0 and 1.1) and how well they adhere to those standards … Happy caching!
Sources/ read on:

(Disclaimer: there might well be some errors in here, feel free to correct me if I missed something!)

Koffieculturen

Als de kwaliteit van de koffie een bepalende factor is in mijn beroepsgeluk (en geloof me, dat is zo), dan ben ik hier in Brussel een tevreden drinker. Net zoals in Mechelen (bij dat andere telco-bedrijf) brouwen hier grote, donkere machines van Maas International echt goeie koffie op verzoek. Bekertje voor bekertje, met echte gemalen koffie, de eerste twee van de dag gratis, daarna 15 cent per portie.
Absoluut geen reden om een Starbucks in de buurt te zoeken dus en voor zover ik weet is dat er ook niet in Brussel. Misschien staan we nog niet op die sport van de koffie-ontwikkelingsladder, want in de USA lijkt het cafeïne-snobisme (“a Venti Caramel Macchiato to go please”) veel meer aanwezig, als je films en televisie-series als Sex and the City of Ally McBeal mag geloven. En anderzijds zie je bv. in de coffee-loving “Gilmore girls” die andere uiting van koffie in de States; achter de toog van de diner een grote kan met urenlang verwarmde zwarte prut die -beeld ik me in- toch echt niet beter kan zijn dan het zurige afwaswater dat bij mijn ex-werkgever uit Gent uit de grote Miko-percolator in schilferende thermoskannen kwam gepist?
Nee, laat mij maar aanschuiven bij Maas’ machines voor mijn fix. En thuis, thuis zet ik hem zelf, en bedenk ik dat ik ook daarvoor de Atlantische Oceaan niet over moet.