Adding GIT SHAs to your application's HTTP headers
blog.andrewvc.com
blog.andrewvc.com
#!/bin/sh
git-diff `curl -s "http://www.yourapp.com/_revision"`
Get your paths squared away, chmod +x it, then type in: git diff-prod
And boom! Instant diff with head in production.Of course, you might want to get your deploy scripts squared away for figure out why your servers aren't restarting if thats the reason for this.
It's actually really useful when coupled with Rails+Unicorn w/ downtimeless deploy. Every once in a while unicorn will run a deploy but stop picking up code changes, and this is a good way to verify that your deploy didn't go all the way through.
Additionally, it integrates with shell scripts easier than most other solutions. Lastly, if you really want you don't need to make it an HTTP header, you can just make a special /git_sha page that renders it out if you're really worried.
Additionally, GIT_SHAs are good for cache busting in some situations (though totally inappropriate for others).
does not work with heroku since they strip the .git folder... we should probably add that to the readme
[1] They could still exist for hints or what not, but I presume reasonably advanced caches will be able to heuristically figure out how long the content lasts and do things like start sending results while waiting on the header to return... with some sort of reset if it turns out to be a bad cached result.
(honestly I had never even heard of it before just now).
2) A well designed app will hopefully not have every page rendered dynamically at the server anymore, but just have an api to send data back to the page for rendering client side. This benefits from content caching (provided the content is big enough to benefit from caching rather than retransmission).
3. Using something like varnish in front of your site will allow you to dynamically invalidate the hash when needed, and in the interim, a generated result to a url is no different than a static one.
2) how do you send such content? suppose it's in the db, you need to convert it to a wire format (json or whatever) and then generate an hash for it, but you do not need to, you could just send a revision id as ETag without even reading the full data from the db
3) whatever you want to do with an hash, you can do using an hash as the etag. The latter is simply more generic
2) So I see what you are saying, but you are wrong -- the ETag still requires a lookup of "did content change since then, based on this tag". My system does not preclude a similar mapping of (tag value, last change) in the server.
3) Yeah, I know, my point is that a standardized hashing method for the ETag provides benefits on top of the ETag. Sometimes everyone playing nicely together actually works out better than lots of flexibility.
http://code.google.com/webtoolkit/doc/latest/DevGuideCompili...
I'm surprised i don't see this type of thing more often in other libraries.