ETag + If-Match = PUT

2007-08-21 @ 10:35#

it just dawned on my this morning that, if i want to properly support PUT, i *must* provide full and proper support for ETags. i current generate ETags for all my content - cool. I also support ETags on GET/HEAD requests (using If-None-Match to cut down on bandwidth. also cool. but i do not use ETags for PUT and that's a bummer.

currently i only support PUT for updating content. that means i can 'skirt' the rules a bit since i will do a check for the doc-id and reject PUT if the doc-id does not exist. of course, this does mean i am subject to the lost update problem. I need to support If-Match (and If-Not-Modified) to prevent updates getting clobbered. it's all good.

but i also realized (today) that, if i get support for If-Match in place for PUT, i can also implement If-None-Match for PUT and that will allow me to support PUT for creating new resources. that's a big win, imho.

i'll need to change some other parts of my framework to get rid of my hard-coded PUT-as-update-only pattern, but that's fine. once this is in place, i'll have a lot more flexibility - esp. for my XmlFileHandler plug-in that supports creating documents on disk.

just gotta remember the mantra:

ETag + If-Match = PUT