Replace all '?'s in URLs with '%1F' (the ASCII unit separator char), and a middleware to undo it before your rack app sees.
Tom Lea
gem "cachable_url", "~> 1.0.0"