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.


Aug 26 2006

HttpCaching: a PHP class to provide HTTP caching information

Tags: , , , Filed under: Written in Englishhugo @ 12:12

In order to make it easier to provide HTTP caching information in my PHP scripts, I wrote a tiny PHP 5 class: HttpCaching.

It’s very basic and I had more fun playing with Doxygen than with PHP while writing it, but people might find it useful.