Fix race conditions from ETag middleware with lock