This is a read-only archive!

Fun with HTTP headers

One fun thing about playing with Compojure is that it doesn't do much with HTTP headers for you, which is a good learning opportunity. RFC 2616 is rather helpful here.

For example I learned that if you don't set a Cache-Control or Expires header, your browser will happily re-fetch files over and over, which is a bit of performance hit. Static files that don't change often like images etc. can be set with a higher Expires value so they're cached.

Another thing to keep in mind (note to self) is that using mod_proxy to forward traffic to a local Jetty server means that the "remote IP" you get from (.getRemoteAddr request) will always be 127.0.0.1. If you want the user's real remote IP, you have to look in the X-Forwarded-For header (easily accessed as (:x-forwarded-for headers) in Compojure. Given that Identicons are generated from a hash of an IP address, this has resulted in some screwed up (wrongly identical) avatars for a bunch of people in posts for the past couple days. Oops. Not much I can do to fix that now.

In other non-news, I just the spam logging for the blog so I can see the kinds of things bots are doing to get around my feeble anti-spam measures. Sadly the spam seems to have stopped entirely, right after I set this up. How annoying.

This post is related to Darn you, spammers.
March 17, 2009 @ 3:14 PM PDT
Cateogory: Programming

2 Comments

Gen2ly
Quoth Gen2ly on March 17, 2009 @ 4:53 PM PDT

Nice! Thewebsite is definitely looking good. Light and lean.

Brian
Quoth Brian on March 18, 2009 @ 2:59 AM PDT

Thanks. I don't care too much for the layout though. We'll see.