Oct 08 2006

Anti-leeching version 2: image annotation and HTTP caching

Tags: , , , Filed under: Written in Englishhugo @ 18:39

A few months ago, I set up anti-leeching measures on my site as I was tired of people stealing my photos, both because they never ask, and because I was providing free bandwidth to all the MySpace junkies. I was looking where the request was coming from, and returning an error if it wasn’t from a legit source.

I later removed this, as bandwidth is basically free for me (DreamHost just doubled the quotas to 2TB/month, so I’ve got nothing to worry about on this side – see my DreamHost guide for more info).

Annotating photos with copyright information

So I was still bugged by the other side of the problem: people stealing my photos, not that they’re very valuable, but just as a matter of courtesy. I ended up finding another parade: annotating my images when they’re served from external sources.

Here is an example: my most popular photo (the one that even Alain de Botton enquired about for one of his books) ends up on various fora all the time:

Thumbnail of Japanese toilet photo

So, if it’s linked from this blog, I serve it normally, and otherwise I annotate it with copyright information.

HttpCaching: now returning 304 Not Modified automatically

This is why I got more interested in HTTP caching in PHP a while back, as computing those images takes both time and CPU. HttpCaching now deals with returning 304’s automatically with version 0.5 that I just released, so well behaved HTTP clients should have a good experience.

If the PHP code for annotating photos is of any interest to people, I’ll look into making it available too. The issue is that there’s quite a few hard-coded things in it which make it not easy to reuse at this point.

One Response to “Anti-leeching version 2: image annotation and HTTP caching”

  1. Mark Nottingham says:

    Cool!

    Have you seen cgi_buffer (horrible name, yes)? It does gzip Content-Encoding and ETag validation as well, and makes the connection persistent if possible…

    Beware, I haven’t updated it in a long time, but you might find some of it useful (I especially like that it’s a one-line include).

    Cheers,

    Mark

Leave a Reply

Please copy the string AkZ0Pe to the field below: