I'm not sure which is less expensive, setting accept = req.headers.get('Accept') and then testing it, or using "in" and only fetching the data if it is there. Did you check both?